How to install and configure DB2 ODBC driver

The following shows you how I got an ODBC connection to DB2 on a Windows Server 2008R2. After doing a search on the Internet I found this page that really helped me a lot. They do it a bit different.

NEW
If you also want to install the IBM Control Center you might want to look at this page. This also installs the ODBC out-of-the-box.
IBMCS
If your need a 32 or 64-bit version for Windows and DB2 version 9.7. You should look for something like this.
IBMDB2CS

On this page you can find and download the ODBC-drivers that fits your system. I you don’t know what version of DB2 that you’re running, you can contact your DBA. The DB2-version can be found using the command DB2level.
IBM homepage

Choose either ODBC 32-bit or 64-bit for your DB2-version and download it for Windows.

If your need a 64-bit version of the ODBC-driver for Windows and DB2 version 9.7. You should look for something like this.
IBM download

NB! You need to create an IBM-account to download the file.

Copy the content of ZIP-file containing the ODBC-driver that you just downloaded to c:\program files\IBM. The path is optional, you can choose a different path if you want to or are using a 32-bit ODBC-driver. The files and folders in c:\program files\IBM, should look something like this.
Dirlist

Start a Windows command-prompt as administrator. If you don’t know how to do this, you can take a look at this page.

Go to the folder c:\program files\IBM\bin and type db2oreg1 –i (if you later want to uninstall it type db2org1 –u).
commandprompt

Go to the folder c:\program files\IBM\bin and type db2oreg1 –setup (Thanks to Noel for this comment).
pic13480

This will register the DB2 ODBC-driver in Data Sources (ODBC) on Windows. You can take a look at the drivers tab.
ODBC

 

 

 

 

 

 

 

 

 

NB! If you have installed af 32-bit version of the ODBC-driver on a 64-bit system, then you have to look in the 32-bit version of the ODBC Administrator to find the driver. The 32-bit version of the ODBC Administrator can be found here: C:\Windows\SysWOW64\odbcad32.exe (Thanks to Grae for this comment)

Now you have to setup a ODBC-driver for DB2. You can either make a System or User DSN.
In this example i’m creating a User DSN. Go to the User DSN-tab and press the Add-button.
EmptyODBC

 

 

 

 

 

 

 

 

 

Choose the DB2 ODBC-driver and press the Finish-button.
ODBCAdd

 

 

 

 

 

 

 

 

 

Give the DSN a name that you can use in your programs. Here I have just given it the name DB2DB.
ODBCAddName

 

 

 

 

 

 

 

 

 

Then press the Add-button and go to the Advanced Settings-tab.
Advancedtab

Here you need to press the Add-button to add the settings below.
Database: Should point to the database that you want to connect to.
Hostname: Should point to the server where your DB2-server is installed.
Port: The portnumber where the DB2-server on the Hostname is responding.
Protocol: The protocol used to connect to the DB2-server. There’s different options as you can se in the picture below.
ProtocolOptions

The final settings should be the ones listed below.

AdvancedtabWithOptions

Now you press the OK-button and you have a new DB2 ODBC connection and your done. You can now use this DB2 ODBC connection in your different programs.
FinalCreation

 

 

 

 

 

 

 

 

 

NOTE
If you get the error described below in SAS. Then you most likely didn’t install the correct version 32/64-bit for your operating system. Install the correct bit-version of the Control Center from the IBM DB2 Client Server pack (further information at the start of this post).

The SAS/ACCESS Interface to DB2 cannot be loaded. The SASDBU code appendage could not be loaded

64 thoughts on “How to install and configure DB2 ODBC driver

  1. This is awesome! Could not find any documentation even remotely close to this on the IBM website. One extra step I had to do was run “db2oreg1 -setup” after running “db2oreg1 -i” since the ODBC Administrator wizard had trouble creating the required config files on the fly when setting up the connection.

    • Great instructions, thanks!!! And the db2oreg1 –setup command in this comment also saved me, before running it none of my CLI properties would stick when configuring the ODBC Data Source.

  2. Hello,

    I was successfully able to install the driver Downloaded from the above link but Instead of IBM DB2 ODBC Driver I am getting IBM DATA SERVER for ODBC . I want IBM DB2 ODBC Driver . How to go about it . Your help is much appreciated . Thanks ,
    Abhijeet

  3. Clear set of instructions – been looking over lots of IBM pages for something like this.

    I’m trying to install the driver on several new Windows 7 (64 bit) PC’s. after doing the db2oreg1 commands I still don’t get the DB2 driver in the ODBC Administrator.

    is there somewhere it could be blocked, or is v10.5 different ?

    Dr John

    • Hi John

      I must admit that I haven’t tried to install other versions of the driver or on any other OS.
      I hope that someone reading your comment will be able to help you.

    • When you run db2oreg1 you need to do this as administrator, otherwise the command helpfully fails silently. So click on the start button, right click on Command Prompt and select Run As Administrator. Then run db2oreg1.

    • Hi Victory

      Sorry for the late response.I haven’t had that problem, what OS are you using?
      I can see that another person is having the same problem.

    • ami me sucedia eso al intentar instalar este :

      ibm_data_server_driver_for_odbc_cli_win64_v10.5.zip

      registraba el driver pero no me dejaba crear la coneccion odbc

      al probar este :

      v10.5fp5_ntx64_odbc_cli.zip

      y siguiendo las instruccione todo funciono correctamente

  4. Hello Sir,

    Thanks for putting such a nice article. It was been of great help.

    I followed the step and did manage to get driver installed. I am trying to connect and getting below error.

    SQL8002N

    An attempt to connect to a host failed due to a missing DB2 Connect product or invalid license.

    Please suggest:
    a. Do we need DB2 connect ( version 9.7 64 bit) software ( Licensed version) so that the driver can work
    b. If yes than what is the work around to connect to DB2 ( z/OS) using vbscript or .net using code directly.

    Please note : We don’t have DB2 Connect v9.7 installed in our machine.

    • Hi Manish

      I must admit, that I have absolutely no experience with z/OS.
      I hope that someone reading this will be able to help you.

      • You’ll need to install the full client, then you can use the db2licm command.

        ..\bin\db2licm -a db2consv_ee.lic

  5. Your example doesn’t show how you enter the username. My DB2 instance is running as an AD Domain user (i.e. contoso\zzztsmservice). The driver doesn’t seem to like the backslash for the username.

    How is your DB2 server on Windows running, as a local user on the server, or as a Domain account?

  6. This is a well written article, but I do not see the driver appearing in my odbc datasources. I am using a windows 7 x64 pro system. I followed all of the procedures in your article, and had no problem. I even downloaded the v9.7fp9_ntx64_odbc_cli.zip client, and repeated the procedure. No luck getting the driver to display in the odbc datasource module.

    Any suggestions are greatly appreciated.

    • Strange, some has reported the same because of a 32-bit/64-bit problem. But it seems you have 64-bit all the way through. But you could try looking at the 32-bit version of the ODBC-administrator at C:\Windows\SysWOW64\odbcad32.exe and see if it appears there.

  7. Thank you very much for so detailed tutorial, I successfully connect to my DB2 database just following the steps, it’s awesome!!!
    BTW, when I execute command db2oreg1 -setup, I got stuck for a while because there seemed nothing happened, but when I restart my computer, I see ODBC data source administrator has a new driver point to the location of DB2 ODBC driver with correct version.

  8. Pingback: How To Fix Advanced Installer Odbc Errors - Windows Vista, Windows 7 & 8

  9. after successful creation of DSN, I am accessing it from Visual Studio the same work properly but after deploying the ASP.NET web site on 2003 server below error occur.
    ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

  10. I have this problem, when I test the connection:”SQL1598N An attempt to connect to the database server failed because a licensing problem. SQLSTATE=42968″… I need help, thanks.

  11. Wow, IBM should be paying you big time, you saved my butt. IBM’s site sucks so bad in that it cannot provide this info.

  12. Hi ,

    We do followed the same procedure which was explained above , but i could not able to do test connection . I am getting licensing issue . Did the package comes with *.lic file too ?

    Thanks.

  13. But we are receiving error saying that “SQL1598N – An attempt to connect to the database server failed because of a licensing issue . SQLSTATE=42968 “.

    Any suggestions.??

  14. Great article. A few notes on my experience in getting Excel 2013 to use ODBC to DB2 via MS Query on Win7 64bit… First, had to use the 32 bit driver (think MS Query may still be 32 bit). I used 10.5 and installed as above, using both the commands above to register it (being sure to run cmd shell as administrator). From there used 32 bit ODBC to confirm driver was available and to set up a *User* DSN as described above (Excel does not seem to see system DSN’s). Final key to the puzzle is to run Excel in compatibility mode for Win XP SP3 (right click on Excel and set).

  15. A couple of hints:
    1. At the command prompt, it seems the command to install has changed. Type:
    db2cli uninstall -setup
    Note: To access help, type db2cli -help
    2. In Windows 10 or Windows 8, installation must be run from an Administrator Command Prompt. Right click Command Prompt in Apps, and choose More > Run as administrator. If run from a regular Command Prompt, installation will appear to complete correctly, but the required registry entries will not be added, and the driver will not appear in odbcad32.exe.

  16. Thanks to this document I was able to finish my installation, so I want to give it an additional input in gratitude.
    For some unknown reason my ODBC Administrator crashed and I have been forced to install de 32 bits version drivers. As per DB2 10.5.7 there are no 32 bits drivers for windows available for download, but that’s because they are included on the 64 bit download.
    Which are db2cli.dll and db2odbc.dll (similar to the 64 bit ones but without the “o”).
    In order to register the 32bit drivers we will have to use “db2oreg123” instead
    I hope that this info may be helpful for someone else. Additional info can be found here:
    http://www-01.ibm.com/support/docview.wss?uid=swg21384435

  17. Hello Dear,
    Very clear explanation which helped me a lot. but unfortunately I got messed up with somethings.
    Added drive successfully, then to rename the “Host name” I deleted it and tried adding it once again but I’m unable to add the drive with same “Data Source Name”.
    One more thing is that, deleted driver “database alias” still reflects in its dropdownlist.

    Could you please suggest me something how to over this thing.
    Thanks a lot. Good Day..!!

  18. Thanks for the post.
    I need help to configure IBM DB2 ODBC Driver – DB2COPY1, where i need to setup through CMD line because I am automating through puppet. I dont wana use GUI.

    DSN configured as: ABCD
    USER ID: USER!@#
    Password: nsfnda
    Port Number: 3134
    Hostname: dfg-qwer-app.novonet
    Subsystem: ABC

    I tried with these command
    >db2cli registerdsn -add DATG_Print
    >db2cli writecfg add -dsn DATG_Print -database BLUDB -host datg-db2-app.via.novonet -port 3134

    Any help would be appreciated

    • I Have the same problem, I tried it with copiying the regestry keys, but they don’t contain all data stored in the GUI.

      Have you found a way to automize that?

Leave a Reply

Your email address will not be published. Required fields are marked *