DB2 Version 9.7 for Linux, UNIX, and Windows

Registering ODBC data sources for applications that use the IBM Data Server Driver for ODBC and CLI

You must install and configure the IBM® Data Server Driver for ODBC and CLI before an ODBC database application can use the driver. This driver is not part of the IBM Data Server Client or the IBM Data Server Runtime Client.

About this task

The name of the IBM Data Server Driver for ODBC and CLI library file is db2app.dll on Windows operating systems, and db2app.lib on other platforms. The driver library file is located in the lib subdirectory of the directory in which you installed the driver.

If you have multiple copies of the IBM Data Server Driver for ODBC and CLI installed, ensure that the intended copy is identified in the odbc.ini file. When possible, avoid installing multiple copies of this driver.

Before you begin

To register a database as an ODBC data source and associate the IBM Data Server Driver for ODBC and CLI with the database, you need the following things:

Procedure

This procedure depends on which driver manager you are using for your applications.

Results

Whenever you create a Microsoft ODBC data source by using the ODBC Driver Manager, you must manually open the ODBC data source Administrator and create a data source by checking the contents of the db2cli.ini file or the db2dsdriver.cfg file. There is no command-line utility that reads the db2cli.ini file or the db2dsdriver.cfg file and creates a Microsoft ODBC data source. The db2cli command provides additional options to create a Microsoft ODBC data source through the registerdsn command parameter, which offers the following functions:
  • Registers a Microsoft system or user ODBC data source if a data source entry is available in the db2cli.ini or db2dsdriver.cfg file or in the local database directory as a cataloged database.
  • Lists all the DB2 system or user data sources that are already registered in the Microsoft Data Source Administrator.
  • Removes the system or user data sources that are already registered in the Microsoft Data Source Administrator.
Note: The db2cli registerdsn command is supported only on Microsoft Windows operating systems.

Example

You want to register ODBC data sources with an open source driver manager under the following conditions:
  • The operating system for the target database server is AIX®.
  • There are two copies of the IBM Data Server Driver for ODBC and CLI installed at
    • $HOME/db2_cli_odbc_driver1 and
    • $HOME/db2_cli_odbc_driver2
  • You have two ODBC database applications:
    • ODBCapp_A
      • ODBCapp_A connects to two data sources, db1 and db2
      • The application should use the copy of the driver installed at $HOME/db2_cli_odbc_driver1.
    • ODBCapp_B
      • ODBCapp_B connects to the data source db3
      • The application should use the copy of the driver installed at $HOME/db2_cli_odbc_driver2.

To register ODBC data sources with an open source driver manager, add the following entries in the odbc.ini file:

[db1]
Driver=$HOME/db2_cli_odbc_driver1/lib/libdb2.a
Description=First ODBC data source for ODBCapp1, 
       using the first copy of the IBM Data Server Driver for ODBC and CLI

[db2]
Driver=$HOME/db2_cli_odbc_driver1/lib/libdb.a
Description=Second ODBC data source for ODBCapp1, 
       using the first copy of the IBM Data Server Driver for ODBC and CLI

[db3]
Driver=$HOME/db2_cli_odbc_driver2/lib/libdb2.a
Description=First ODBC data source for ODBCapp2, 
       using the second copy of the IBM Data Server Driver for ODBC and CLI