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:
- Connection strings parameters
- db2cli.ini file
- db2dsdriver.cfg file
Before you begin
To
connect to databases with the IBM Data
Server Driver for ODBC and CLI, you need:
- databases to which to connect; and
- one or more copies of the driver installed.
Procedure
To configure connectivity for a database when using the IBM Data Server Driver for ODBC
and CLI, use one of the following methods:
- Specify the database connectivity information in the connection
string parameter to SQLDriverConnect.
- For CLI applications only: put the database
connectivity information in the DB2® CLI
configuration file.
There is no support for the Command
Line Processor (CLP) with the IBM Data
Server Driver for ODBC and CLI. For this reason, you can not update
CLI configuration using the CLP command "db2 update CLI cfg";
you must update the db2cli.ini initialization
file manually.
If you have multiple copies of
the IBM Data Server Driver for
ODBC and CLI installed, each copy of the driver will have its own db2cli.ini file.
Ensure you make the additions to the db2cli.ini for
the correct copy of the driver.
For more information
about the location of the db2cli.ini file, see db2cli.ini initialization file.
- Use the db2dsdriver.cfg configuration
file to provide connection information and parameters. For
example, you can specify the following information in the db2dsdriver.cfg configuration
file, and pass the connection string in SQLDriverConnect() as DSN=myDSN;PWD=XXXXX:
<configuration>
<dsncollection>
<dsn alias="myDSN" name="sample" host="server.domain.com" port="446">
</dsn>
</dsncollection>
<databases>
<database name="sample" host="server.domain.com" port="446">
<parameter name="CommProtocol" value="TCPIP"/>
<parameter name="UID" value="username"/>
</database>
</databases>
</configuration>
- For ODBC applications only: register the database as an
ODBC data source with the ODBC driver manager. For more
information, see Registering ODBC data sources for applications that use the IBM Data Server Driver for ODBC and CLI.
- Use the FileDSN CLI/ODBC keyword to
identify a file data source name (DSN) that contains the database
connectivity information. For more information, see FileDSN CLI/ODBC configuration keyword.
A file DSN is a file that contains
database connectivity information. You can create a file DSN by using
the SaveFile CLI/ODBC keyword. On Windows operating systems, you can use the Microsoft ODBC driver manager
to create a file DSN.
- For local database servers only: use the PROTOCOL and
the INSTANCE CLI/ODBC keywords to identify the
local database.
- Set the PROTOCOL CLI/ODBC keyword
to the value Local.
- Set the INSTANCE CLI/ODBC
keyword to the instance name of the local database server on which
the database is located.
For more information, see Protocol CLI/ODBC configuration keyword and Instance CLI/ODBC configuration keyword.
Example
Here is a list of CLI/ODBC keywords that work with file
DSN or DSN-less connections:
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:
To make a connection to the database in an ODBC application:
- Register the database as an ODBC data source called odbc_db1 with
the driver manager.
- Call SQLConnect with a connection string that
contains: Database=odbc_db1;