Product:
Microsoft Windows 2022 server
DB2 driver
Issue:
Can not connect to DB2 server with ODBC, the dbalias is not found.
Solution:
Inside the ODBC program, you need to setup a alias.
This is controlled by the db2cli.ini file.
If you run a bat file to catalog the sql db2 settings this file will end up in your profile folder, e.g. c:\users\yourname
Copy the file to the common folder c:\programdata\ibm\db2\db2copy1\cfg
Search for db2cli.ini to find the folders to use. The db2cli.ini have lines like below:
[db2instance] DBALIAS=db2instance UID=donald DESCRIPTION=db2instance - PROD
But first, you need to install the db2 drivers from IBM Data Server Client Packages (12.1, All platforms)
Run the setup.exe from inside folder \wib_data_server_client_winx64_v11.1\client\image.
Create a catalog.sql file with the content you need; (you must adjust to your environment)
UNCATALOG NODE db2instance; CATALOG TCPIP NODE db2instance REMOTE db2servername.domain.com SERVER 50000 REMOTE_INSTANCE db2instance OSTYPE LINUX;
The run a command like this from a bat file:
db2cmd db2setcp ” db2 -tvf C:\install\catalog.sql ”
This will give you the User DSN setup.
You can find the values in the registry, download to a reg file, and edit it to be HKLM as below;
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\db2instance] "Driver"="C:\\PROGRA~1\\IBM\\SQLLIB\\BIN\\DB2CLIO.DLL" "Description"="db2instance"
Load this file, and you will get it in System DNS.
Then you need to update the db2cli.ini in the folder c:\programdata\ibm\db2\db2copy1\cfg to get the dbalias.
If it does not work, check the links below.
More information:
https://www.ibm.com/docs/en/db2-warehouse?topic=installing-windows
https://www.ibm.com/support/pages/db2-odbc-cli-driver-download-and-installation-information
Installing and configuring an DB2 ODBC CLI-driver on Windows
https://www.ibm.com/docs/en/db2/11.5.x?topic=commands-catalog-database
https://help.hcl-software.com/bigfix/9.2/platform/Platform/Config/c_creating_db2_dsn.html
https://www.ibm.com/docs/en/db2/11.5.x?topic=odbc-cliodbc-configuration-keywords
https://www.columbia.edu/sec/acis/db2/db2iy/db2iy47.htm
https://www.ninjaone.com/blog/registry-editor/
https://www.techtarget.com/searchwindowsserver/tip/Command-line-options-for-Regeditexe