Registering ODBC data sources for applications that use the IBM Data Server Driver for ODBC and CLI product
You need to register the IBM
Db2® ODBC driver
with the ODBC driver manager when you are connecting to multiple databases from different vendors,
using different versions of the IBM
Db2 ODBC driver,
or when your ODBC application is on the Windows operating
system.
The ODBC driver manager is not part of IBM
data server product installation and must be obtained separately from third-party vendors. In the
Windows operating system, the ODBC driver manager is part
of the operating system.
Before you begin
To register the IBM
Db2 ODBC driver
and data source with the ODBC driver manager, the following requirement must be met.
- You can connect to the target database without using the IBM Db2 ODBC driver
- An ODBC driver manager installed1
- You installed the IBM Data Server Driver for ODBC and CLI product or any IBM data server product. See Installing the IBM Data Server Driver for ODBC and CLI software on Linux and UNIX operating systems for steps to install the IBM Data Server Driver for ODBC and CLI product.
About this task
The name of the IBM Db2 ODBC driver library file is db2app.dll on Windows operating systems, and db2app.lib on other platforms. If you installed the IBM Data Server Driver for ODBC and CLI product, the driver library file is located in the lib subdirectory of the directory in which you installed the IBM Data Server Driver for ODBC and CLI product.
Procedure
Steps to register the IBM Db2 ODBC driver depend on the operating system and the ODBC driver manager you installed.
Results
In Windows operating
system, you can use the db2cli registerdsn command
to create ODBC data source entries from the following sources2.
- The db2cli.ini file
- The IBM data server driver configuration file (db2dsdriver.cfg)
- Database entries that are specified in the LDAP server3
- Lists all the Db2 system or user data sources that are already registered in the Microsoft ODBC Data Source Administrator.
- Removes the system or user data sources that are already registered in the Microsoft ODBC Data Source Administrator.
- Test database connectivity using the ODBC data source entry.
The db2cli registerdsn command is supported only on the Microsoft Windows operating systems.
Example
You want to register ODBC data sources with an open source
driver manager under the listed conditions:
To register ODBC data sources with an open source driver
manager, add the example 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
1 Applicable for operating systems other than the Windows operating system
2 You
can also create ODBC data source entries from the cataloged database
entry. However, you cannot create cataloged database entry with the IBM Data Server Driver for
ODBC and CLI product
and the
IBM Data Server Driver Package product.
3 You
must ensure that you can connect successfully to the LDAP server by
configuring the LDAP section in the IBM data
server driver configuration file or configuring the LDAP connection
in your Windows environment.