I am using a Windows Machine to connect to a remote DB2 instance. Ran into this issue
SQL1531N The connection failed because the name specified with the DSN connection string keyword could not be found in either the db2dsdriver.cfg configuration file or the db2.cli.ini configuration file. Data source name specified in the connection string: <DSN>
I have configured ODBC Data source using ODBC Data Source Administrator
it has connected successfully.
Upon further investigation, I am unable to locate db2dsdriver.cfg on IBM DATA SERVER DRIVER folder. I am able to find db2dsdriver.lvl and dbs2dsdriver.xds. Just not the .cfg file. I am also unsure where HammerDB looks for the config file.
I have looked at the configuration of DB2 from the website but I am unable to get any useful information from there. https://www.hammerdb.com/docs/ch04s02.html
For the tiny footprint
ODBC and CLI driver
(known as clidriver) from IBM, you are responsible for creating and editing thedb2dsdriver.cfg
configuration file. It is a small XML file documented here and in related linked pages. The hammerdb documentation also gives a minimal example and you linked to this page in your question.You can create and edit this file either by command lines to the
db2cli
tool, or by directly editing with a text editor (or XML editor). It may be easier to use an editor than to learn the command lines, although command lines have the advantage that they lend themselves to scripting this activity for larger installations.On Microsoft-Windows you can also use Notepad to create and edit the file
db2dsdriver.cfg
.An important step is that following editing of the file you must first validate its contents before trying any database connections. Validation checks that the syntax of the XML in the file is correct. To validate, you use the
db2cli validate
command described here. It must show a successful result before you try to connect to any database. Once validation completes without errors, you can also usedb2cli validate -connect -dsn XXX -user YYY -passwd ZZZ
to test the connection independently of your application (in this case hammerdb). Once you get a successful connection with thedb2cli validate -connect -dsn ...
then your application (hammerdb) will connect correctly.There are many examples of
db2dsdriver.cfg
contents online , but your first source should be the Db2 Knowledge Centre online, which details the command line options to thedb2cli
command, along with giving examples ofdb2dsdriver.cfg
.If you already have a working Db2 configuration with local and remote databases (but no
db2dsdriver.cfg
file), you can also use a tooldb2dsdcfgfill
to populatedb2dsdriver.cfg
from your existing Db2 configuration. See docs here.