The DB2 Call Level Interface/ODBC driver (which consists of the DB2 Call Level Interface run-time environment and the DB2 ODBC driver) is included with the DB2 Connect Personal Edition.
This support enables applications developed using ODBC and DB2 CLI APIs to work with any DB2 server or DB2 Connect Personal Edition workstation. DB2 CLI application development support is provided by the DB2 Application Development Client which is packaged with a DB2 Connect server.
Before DB2 CLI or ODBC applications can access DB2, the DB2 CLI packages must be bound on any remote server to be accessed by this application. See Binding Database Utilities for specific details.
The following general steps are required on DB2 Connect Personal Edition to give DB2 CLI and ODBC applications access to remote DB2 databases. These instructions assume that you have successfully connected to DB2 using a valid user ID and password. Depending on the platform many of these steps are automatic.
Step 1. | Use the Control Center to add the database so that its instances and databases can be made known to the Control Center, then add the instances and databases for that system. (Your local system is represented by Local icon.) If you do not have access to this program you can use the catalog command in the command line processor. |
Step 2. | The DB2 CLI/ODBC driver is an optional component that you can install. Be sure it is was installed at that point. |
Step 3. | To access the DB2 database from ODBC/CLI:
|
Step 4. | If necessary, you can set various CLI/ODBC Configuration Keywords to modify the behavior of DB2 CLI/ODBC and the applications using it.
|
If you followed the above steps to install ODBC support, and added DB2 databases as ODBC data sources, your ODBC applications will now be able to access them.
Before DB2 CLI and ODBC applications can successfully access a DB2 database from a UNIX client, perform the following steps on the client system:
For more information see the CATALOG DATABASE and CATALOG NODE commands in the Command Reference.
Setting up odbcinst.ini
The settings in this file impact all of the ODBC drivers on the machine.
Use an ASCII editor to update this file. It must have a stanza (section) called [IBM DB2 ODBC DRIVER], with a line starting with "Driver" indicating the full path to the DB2 ODBC driver (db2.o). For example, if the home directory of your end user is /home/thisuser/ and the sqllib directory is installed there, then the correct entry would be:
[IBM DB2 ODBC DRIVER] Driver=/home/thisuser/sqllib/lib/db2.o
Setting up .odbc.ini
The settings in this file are associated with a particular user on the machine; different users can have different odbc.ini files.
The .odbc.ini file must exist in the end user's home directory (note the dot at the start of the file name). Update this file, using an ASCII editor, to reflect the appropriate data source configuration information. To register a DB2 database as an ODBC data source there must be one stanza (section) for each DB2 database.
The .odbc.ini file must contain the following lines:
SAMPLE=IBM DB2 ODBC DRIVER
Indicates that there is a data source called SAMPLE that used the IBM DB2 ODBC DRIVER.
[SAMPLE] Driver=/home/thisuser/sqllib/lib/db2.o Description=Sample DB2 ODBC Database
Indicates that the SAMPLE database is part of the DB2 instance located in the directory /home/thisuser.
InstallDir=/home/thisuser/sqllib/odbclib
Indicates that /home/thisuser/sqllib/odbclib should be treated as the location where ODBC is installed.
For example, if the ODBC Driver Manager has been installed in /opt/odbc, the [ODBC] stanza would look like:
[ODBC] Trace=0 TraceFile=odbctrace.out InstallDir=/opt/odbc
See the sample file in the sqllib/odbclib subdirectory for an example.
Once the .ini files are set up you can run your ODBC application and access DB2 databases. Refer to the documentation that comes with your ODBC application for additional help and information.
There are various keywords and values that can be used to modify the behavior of DB2 CLI/ODBC and the applications using it. The keywords are associated with the database alias name, and affect all DB2 CLI/ODBC applications that access the database.
For information on manually editing this file (db2cli.ini), see Configuring db2cli.ini. For information about the specific keywords refer to the CLI Guide and Reference.
| If you require additional information at this point you can refer to the following topics in Detailed Configuration Information: |
The section Platform Specific Details for CLI/ODBC Access should provide you with all of the information you require. The following additional information is useful where DB2 tool support is not available, and for administrators who require more detailed information.
The following topics are covered in this section:
The CLI/ODBC driver will autobind on the first connection to the database, provided the user has the appropriate privilege or authorization. The administrator may want to perform the first connect or explicitly bind the required files. For more information, see Binding Database Utilities.
DB2 CLI can be configured further by manually editing the db2cli.ini file.
This file contains various keywords and values that can be used to modify the behavior of DB2 CLI and the applications using it. The keywords are associated with the database alias name, and affect all DB2 CLI and ODBC applications that access the database.
By default, the location of the CLI/ODBC configuration keyword file is located in the in the INSTHOME/sqllib/cfg directory (where INSTHOME is the home directory of the instance owner) that is running the CLI/ODBC applications on Linux platforms.
The environment variable DB2CLIINIPATH can also be used to override the default and specify a different location for the file.
The configuration keywords enable you to:
For a complete description of keywords and their usage, refer to the Installation and Configuration Supplement online document.
The db2cli.ini initialization file is an ASCII file which stores values for the DB2 CLI configuration options. A sample file is shipped to help you get started. Refer to the CLI Guide and Reference for information on each keyword.
See Platform Specific Details for CLI/ODBC Access for more information on how to modify this file on your platform.