Quick Beginnings for DB2 Connect
The DB2 Call Level Interface (CLI) run-time environment and the DB2
CLI/ODBC driver are included with DB2 clients as optional components during
install.
This support enables applications developed using ODBC and DB2 CLI APIs to
work with any DB2 server. DB2 CLI application development support is
provided by the DB2 Software Developer's Kit (DB2 SDK) which is packaged
with your DB2 server.
Before DB2 CLI or ODBC applications can access DB2, the DB2 CLI
packages must be bound on the server. Although this will occur
automatically on the first connection if the user has the required authority
to bind the packages, it is recommended that the administrator do this first
with each version of the client on each platform that will access the
server. See Binding Database Utilities for specific details.
The following general steps are required on the client system to give DB2
CLI and ODBC applications access to 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. For complete details, see the section that deals
specifically with your platform.
Step 1.
| Use the Client Configuration Assistant (CCA) to add the database (if you
have separate client and server machines) 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.
| On all platforms other than OS/2 the DB2 CLI/ODBC driver is an
optional component during the DB2 client install. Be sure it is
selected at that point. On OS/2 you must use the Install
ODBC Driver icon to install both the DB2 CLI/ODBC driver and the ODBC
driver manager.
|
Step 3.
| To access the DB2 database from ODBC:
- The ODBC Driver Manager (From Microsoft or other vendor) must already be
installed (this is done by default during the installation of DB2 only on
32-bit Windows systems).
- The DB2 databases must be registered as ODBC data sources. The ODBC
driver manager does not read the DB2 catalog information; instead it
references its own list of data sources.
- If a DB2 table does not have a unique index then many ODBC applications
will open it as read-only. A unique index should be created for each
DB2 table that is to be updated by an ODBC application. Refer to the
CREATE INDEX statement in the SQL
Reference. Using the Control Center you would alter the settings of the
table, then select the Primary Key tab and move one or more columns
from the available columns list over to the primary key columns list.
Any column you select as part of the primary key must be defined as NOT
NULL.
|
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.
| The platform specific details on how to give DB2 CLI and ODBC
applications access to DB2 are divided into the following categories:
|
Before DB2 CLI and ODBC applications can successfully
access a DB2 database from a Windows client, perform the following steps on
the client system:
Step 1.
| The DB2 database (and node if the database is remote) must be
cataloged. To do so, use the CCA (or the command line
processor).
For more information refer to the on-line help in the CCA (or the
CATALOG DATABASE and CATALOG NODE commands in the Command Reference).
|
Step 2.
| Verify that the Microsoft ODBC Driver Manager and the DB2 CLI/ODBC driver
are installed. On Windows 32-bit operating systems they are both
installed with DB2 unless the ODBC component is manually unselected during the
install.
To verify that they both exist on the machine:
- Run the Microsoft ODBC Administrator from the icon in the Control Panel,
or issue the appropriate command from the command line:
odbcad32.exe.
- Click on the ODBC Drivers tab.
- Verify that "IBM DB2 ODBC DRIVER" is shown in the list.
If either the Microsoft ODBC Driver Manager or the IBM DB2 CLI/ODBC driver
is not installed, then rerun the DB2 install and select the ODBC component on
Windows 32-bit operating systems.
|
Step 3.
| Register the DB2 database with the ODBC driver manager as a data
source. On Windows 32-bit 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 either of these methods to
add the data source:
|
Step 4.
|
Configure the DB2 CLI/ODBC driver using the CCA: (Optional)
- Select the DB2 database alias you want to configure.
- Click on the Properties push button. The Database
Properties window opens.
- Click on the Settings push button. The CLI/ODBC Settings
window opens.
- Click on the Advanced push button. You can set the
configuration keywords in the window that opens. These keywords are
associated with the database alias name, and affect all DB2
CLI/ODBC applications that access the database. The online help
explains all of the keywords, as does an appendix in the Installation and Configuration Supplement online manual.
|
Step 5.
| If you have installed ODBC access (as described above), you can now access
DB2 data using ODBC applications. Start the ODBC application and go to
the Open window. Select the ODBC databases file type.
The DB2 databases that you added as ODBC data sources will be selectable from
the list. Many ODBC applications will open the table as read-only
unless a unique index exists.
|
Before DB2 CLI and ODBC applications can successfully
access a DB2 database from an OS/2 client, perform the following steps
on the client system:
- The DB2 database (and node if the database is remote) must be
cataloged. To do so, use the CCA (or the command line
processor).
For more information see the on-line help in the CCA
- If you are using ODBC applications to access DB2 data, perform the
following steps. (If you are using only CLI applications, skip this
step and go to the next step.)
- Check that there is an ODBC Driver Manager installed. The ODBC
Driver Manager is not installed with DB2; we suggest you use the Driver
Manager that was shipped with your ODBC application. Also ensure that
the DB2 CLI/ODBC driver is installed:
- Run the ODBC Administration tool as described in its documentation.
This is usually done in one of two ways:
- Double-click on the ODBC Folder in OS/2, and double-click on
the ODBC Administrator icon.
- Run odbcadm.exe from the command line.
The Data Sources window opens.
- Click on the Drivers push button. The Drivers window
opens.
- Verify that "IBM DB2 ODBC DRIVER" is shown in the list.
If the ODBC Driver Manager is not installed then follow the installation
instructions that came with your ODBC application. If the IBM DB2
CLI/ODBC driver is not installed then double-click on the Install ODBC
Driver icon in the DB2 folder to install the DB2 CLI/ODBC driver.
- Register the DB2 database with the ODBC driver manager as a data
source using either of these methods:
- Using the CCA:
- Select the DB2 database alias that you want to add as a data
source.
- Click on the Properties push button.
- Select the Register this database for ODBC check box.
- Using the ODBC Driver Manager:
- Run the ODBC Driver Manager, as described in its documentation.
This is usually done in one of two ways:
- Double-click on the ODBC Folder in OS/2, and double-click on
the ODBC Administrator icon.
- Run odbcadm.exe from the command line.
- Click on the Add push button from the Data Sources
window. The Add Data Source Window opens.
- Double-click on the IBM DB2 ODBC DRIVER in the list.
- Select the DB2 database to add and click on OK.
- Configure the DB2 CLI/ODBC driver using the CCA: (Optional)
- Select the DB2 database alias you want to configure.
- Click on the Properties push button. The Database
Properties window opens.
- Click on the Settings push button. The CLI/ODBC Settings
window opens.
- Click on the Advanced push button. You can set the
configuration keywords in the window that appears. These keywords are
associated with the database alias name, and affect all DB2
CLI/ODBC applications that access the database. The online help
explains all of the keywords, as does an appendix in the Installation and Configuration Supplement manual.
- If you have installed ODBC access (as described above), you can now access
DB2 data using ODBC applications. Start the ODBC application and go to
the Open window. Select the ODBC databases file type.
The DB2 databases that you added as ODBC data sources will be selectable from
the list. Many ODBC applications will open the table as read-only
unless a unique index exists.
The section Platform Specific Details for CLI/ODBC Access should provide you with all of the information you
require. Installation and Configuration
Supplement includes additional information on setting up and using DB2 CLI and
ODBC applications. (The online Installation and
Configuration Supplement manual is located in the directory x:\doc\en\html,
where x: is the letter that designates your CD-ROM and en is
the two-character country code that represents your language, for example
en for English.) This information is useful where DB2 tool
support is not available, and for administrators who require more detailed
information.
The following topics are covered in the Installation
and Configuration Supplement online manual:
- How to Bind the DB2 CLI/ODBC Driver to the Database
- How to Set CLI/ODBC Configuration Keywords
- Configuring db2cli.ini
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
[ DB2 List of Books |
Search the DB2 Books ]