Background: I’m trying to connect to a DB2 instance, running on a Windows machine. I imagine that this procedure will work just as well for instances running on other architectures. And I’m trying to connect from another Windows machine, to pass data into a Microsoft SQL-powered data warehouse.
You will need the “IBM Data Server Driver for ODBC and CLI (Windows/x86-32 32 bit) V10.5 Fix Pack 8“. If the link doesn’t work any more, go to IBM Fix Central and search for “Windows Data Server Driver ODBC 10.5”. Possibly other versions will work, but this is the one I found most reliable.
The process is as follows:
- Copy the entire extracted folder to the root of a data drive (e.g. to D:\DB2, E:\DB2 as the case may be).
- Add the bin folder to the computer’s PATH environment variable (DB2\clidriver\bin).
- Launch an elevated command prompt.
- Navigate to the DB2 bin folder. E.g.:
- Install the ODBC driver:
- On Windows Server 2012 R2, also run:
- The driver will now appear in the 32-bit ODBC driver list:
- Launch the 32-bit ODBC data source administration applet.
- On the User DSN or System DSN tab, click Add.
- Select the ODBC driver and click Finish.
- Name the data source (e.g. “CSM”, in my case) and then click “Add”, next to the Database alias dropdown.
- Enter User ID and password.
- Check the “Save password” box. Note the warning and click OK.
- Switch to the Advanced Settings tab.
- Use the “Add” button, to enter the following values.
Hostname: [host DNS name or IP address] Port: 50000 Protocol: TCP/IP Database: [DB name, e.g. CTI_DATA]
- Review the settings and click OK:
- To test the connection, first click the “Configure” button.
- The credentials are stored in the ini file, so you do not need to enter them here. Simply click “Connect”.
- You should see a success message.
If you’re looking for a free, Windows-based ODBC interrogation program, there are a few out there. All the ones I tried had quirks in their interfaces. I’ve had most success with ODBC query tool though. Here it is, running under Windows 10:
If that doesn’t work for you, you can try the almost identically named ODBC QueryTool.