Connecting to databases 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.
Before you begin
- Databases to which to connect; and
- One or more copies of the driver installed.
- For more information, see Installing the IBM Data Server Driver for ODBC and CLI software on Linux and UNIX operating systems.
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 listed order:
- Connection strings parameters
- db2cli.ini file
- db2dsdriver.cfg file
Procedure
To configure connectivity for a database when using the IBM Data Server Driver for ODBC and CLI, use one of the listed methods:
Example
Here is a list of CLI/ODBC keywords that
work with file DSN or DSN-less connections:
- AltHostName CLI/ODBC configuration keyword;
- AltPort CLI/ODBC configuration keyword;
- Authentication CLI/ODBC configuration keyword;
- BIDI CLI/ODBC configuration keyword;
- FileDSN CLI/ODBC configuration keyword;
- Instance CLI/ODBC configuration keyword;
- Interrupt CLI/ODBC configuration keyword;
- KRBPlugin CLI/ODBC configuration keyword;
- Protocol CLI/ODBC configuration keyword;
- PWDPlugin CLI/ODBC configuration keyword;
- SaveFile CLI/ODBC configuration keyword;
- DiagLevel CLI/ODBC configuration keyword;
- NotifyLevel CLI/ODBC configuration keyword;
- Security CLI/ODBC configuration keyword;
For
the examples, consider a database with the listed 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
- The transfer protocol is
TCPIP
.
To make a connection to the database in a CLI application,
you can perform one of the listed actions:
- Call SQLDriverConnect with a connection string
that contains:
Database=db1; Protocol=tcpip; Hostname=11.22.33.44; Servicename=56789;
- Add the example
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:
- 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;