Setting up the Windows CLI environment

On Windows platforms, CLI driver must be registered with the Windows ODBC Data Source Administrator (odbcad32.exe), before it can be used by an ODBC application.

Before you begin

Before setting up the Windows CLI environment, ensure that the CLI environment is set up.

About this task

The CLI driver implements both CLI application programming interface (API) and the ODBC API. In Windows environment, CLI driver must be registered with the Windows ODBC Data Source Administrator (odbcad32.exe) before it can be used by an ODBC application. When using the ODBC Data Source Administrator on Windows 64-bit platforms, by default ODBC data sources can be configured only for 64-bit applications. ODBC data sources for 32-bit applications should be configured by using the Microsoft 32-bit ODBC Data Source Administrator (32-bit odbcad32.exe) that is included with the Windows 64-bit operating system.
  • To set up Data Sources for 32-bit applications, you must use %WINDIR%\SysWOW64\odbcad32.exe.
  • To set up Data Sources for 64-bit applications, you must use %WINDIR%\System32\odbcad32.exe.

Procedure

Before CLI and ODBC applications can successfully access a Db2® database from a Windows client, perform the listed steps on the client system:

  1. Verify that the Microsoft ODBC Driver Manager and the CLI/ODBC driver are installed.
    On Windows operating systems, both drivers are installed with the Db2 database products. If a newer version of the Microsoft ODBC Driver Manager is already installed or you manually cleared the option to install it, the Microsoft ODBC Driver Manager is not installed. To verify that both drivers are installed perform the listed actions:
    1. Double-click the Microsoft ODBC data sources icon in the Control Panel, or run the odbcad32.exe command from the command line.
    2. Click the Drivers tab.
    3. Verify that the IBM DB2 ODBC DRIVER - Db2_Copy_Name is shown in the list.
      Db2_Copy_Name is the Db2 copy name that you want to use. See Multiple Db2 copies on the same computer (Windows) for more information.
    If either the Microsoft ODBC Driver Manager or the IBM® Data Server Driver for ODBC and CLI is not installed, then rerun the Db2 installation and select the ODBC component on Windows operating systems.
    Note: The latest version of the Microsoft ODBC Driver Manager is included as part of the Microsoft Data Access Components (MDAC) and can be downloaded from www.microsoft.com.
  2. Register the Db2 database with the ODBC driver manager as a data source.
    On Windows operating systems, you can make the data source available to all users of the system (a system data source), or only the current user (a user data source). Use any of these methods to add the data source:
    • Use the db2cli command with the registerdsn parameter:
      • Issue the db2cli command for each data source that you want to add as follows:
        db2cli registerdsn -add data-source-name
    • Use the Microsoft ODBC Administration tool, which you can access from the Control Panel or by running the odbcad32.exe command from the command line:
      1. The list of user data sources is shown by default. If you want to add a system data source click the System DSN button, or the System DSN tab (depending on the platform).
      2. Click Add.
      3. Double-click the IBM Db2 ODBC DRIVER - Db2_Copy_Name in the list. Db2_Copy_Name is the Db2 copy name that you want to use.
      4. Select the Db2 database to add and click OK.
    • Use the CATALOG command to register the Db2 database with the ODBC driver manager as a data source. For example:
         CATALOG [ user | system ] ODBC DATA SOURCE
      Using this command, an administrator can create a command line processor script to register the required databases. This script can then be run on all computers that require access to Db2 databases through ODBC.

Results

After configuring the Windows CLI environment, you can now access Db2 data source from Windows ODBC applications.