DB2 Version 9.7 for Linux, UNIX, and Windows

Connecting to databases with the IBM Data Server Driver for ODBC and CLI

The IBM® Data Server Driver for ODBC and CLI is not part of the IBM Data Server Client or the IBM Data Server Runtime Client. It must be installed and configured separately. The IBM Data Server Driver for ODBC and CLI does not create a local database directory. This means that when you use this driver, you must make connectivity information available to your applications in other ways.

About this task

There are several ways to specify connectivity information so that your CLI and ODBC database applications can use the IBM Data Server Driver for ODBC and CLI to connect to a database. When CLI settings are specified in multiple places, they are used in the following order:
  1. Connection strings parameters
  2. db2cli.ini file
  3. db2dsdriver.cfg file

Before you begin

To connect to databases with the IBM Data Server Driver for ODBC and CLI, you need:

Procedure

To configure connectivity for a database when using the IBM Data Server Driver for ODBC and CLI, use one of the following methods:

Example

For the following examples, consider a database with the following properties:
  • the database or subsystem is called db1 on the server;
  • the server is located at 11.22.33.44;
  • the access port is 56789; and
  • the transfer protocol is TCPIP.
To make a connection to the database in a CLI application, you could do one of the following:
  • Call SQLDriverConnect with a connection string that contains: Database=db1; Protocol=tcpip; Hostname=11.22.33.44; Servicename=56789;
  • Add the following to db2cli.ini:
    [db1]
    Database=db1
    Protocol=tcpip
    Hostname=11.22.33.44
    Servicename=56789
To make a connection to the database in an ODBC application:
  1. Register the database as an ODBC data source called odbc_db1 with the driver manager.
  2. Call SQLConnect with a connection string that contains: Database=odbc_db1;