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.
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, listed requirements must be met:
- Databases to which your ODBC applications connect
- An ODBC driver manager installed
- One or more copies of the IBM Data Server Driver for ODBC and CLI installed
- one or more copies of the driver installed.
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.
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 listed 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 listed 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 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
Every time when a Microsoft ODBC Data Source (using ODBC
Driver Manager) has to be created, user has to manually open the ODBC
Data Source Administrator and create a Data Source by checking the
contents of
db2cli.ini or the
db2dsdriver.cfg files. There is no command line utility which reads the
db2cli.ini file or the
db2dsdriver.cfg file and creates a Microsoft ODBC Data Source. Hence to overcome this concern, the
db2cli provides additional options to create a Microsoft ODBC Data Source through the
new
registerdsn command parameter which offers
the listed functions:
- Register a Microsoft System/User ODBC Data Source if a Data Source entry is available
in db2cli.ini or in db2dsdriver.cfg file
- Register all the Data Sources available in the db2cli.ini
file or the db2dsdriver.cfg file at
the same time. The data sources can be registered either as a System
Data Source or as a User Data Source
- Lists all the DB2 System
or User Data Sources that are already registered in the Microsoft Data Source Administrator
- Remove the System or User Data Sources that are already registered
in the Microsoft Data Source
Administrator
Note: The db2cli registerdsn is supported
only on Microsoft Windows platforms.