标签:
The DB2 Call Level Interface (CLI) run-time environment and the ODBC driver are included with the DB2 Client Application Enabler. This is contained on the DB2 Client Application Enablers CD-ROM or can be downloaded from the Web page at http://www.software.ibm.com/data/db2.
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 part of the separately orderable DB2 Application Development Kit product.
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.
After the platform specific instructions there are further details on the following topics:
|
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:
For more information refer to the on-line help in the CCA (or the CATALOG DATABASE and CATALOG NODE commands in the Command Reference).
To verify that they both exist on the machine:
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, or double-click on the Install ODBC Driver icon in the DB2 program group in Windows 3.x.
The Command Reference contains more information on the CATALOG command:
CATALOG [ user | system ] ODBC DATA SOURCE
For information on manually editing this file (db2cli.ini), see Configuring db2cli.ini.
Although not directly related to DB2, some users have experienced problems when running 16-bit ODBC applications on Windows 32-bit operating systems.
Both 16- and 32-bit applications use the same 32-bit IBM DB2 CLI/ODBC Driver. The Microsoft ODBC Driver Manager takes care of the conversion between the 16-bit application and the 32-bit ODBC driver.
Some 16-bit applications were shipped with an old set of 16-bit Driver Manager DLLs (that is, before 1995). These DLLs do not function well in the 32-bit environment. The following symptoms may occur when running the old DLLs:
If (and only if) you are experiencing these problems you may want to update the Microsoft 16-bit ODBC Driver Manager DLLs. These files are provided with DB2 in the SQLLIB\MSODBC16 subdirectory. Use these new DLLs to replace the older versions that are located in the system subdirectory of the Windows operating system directory.
|
If you require additional information at this point you can refer to the following topics in Detailed Configuration Information: |
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:
For more information see the on-line help in the CCA or Configuring Database Connections.
The Data Sources window opens.
If either the ODBC Driver Manager or the IBM DB2 CLI/ODBC driver is not installed then double-click on the Install ODBC Driver icon in the DB2 folder to install both the DB2 CLI/ODBC driver and the ODBC driver manager.
For information on manually editing this file (db2cli.ini), see Configuring db2cli.ini.
|
If you require additional information at this point you can refer to the following topics in Detailed Configuration Information: |
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 Chapter 10. Configuring Client-to-Server Communications Using the Command Line Processor or 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 /u/thisuser/ and the sqllib directory is installed there, then the correct entry would be:
[IBM DB2 ODBC DRIVER] Driver=/u/thisuser/sqllib/lib/db2.o
See the sample file in the sqllib/odbclib subdirectory for an example.
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 be copied into the end user‘s home directory and called .odbc.ini. 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 sample odbc.ini template shows:
SAMPLE=IBM DB2 ODBC DRIVER
Indicates that there is a data source called SAMPLE that used the IBM DB2 ODBC DRIVER.
[SAMPLE] Driver=/u/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 /u/thisuser.
InstallDir=/u/thisuser/sqllib/odbclib
Indicates that /u/thisuser/sqllib/odbclib should be treated as the location where ODBC is installed.
Note: | If your application specifically installed the ODBC components (such as the Driver Manager) elsewhere, you must update the line starting with InstallDir under the [ODBC] stanza to reflect this new location.
For example, if ODBC 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. You can also see How to Configure ODBC.INI for more detailed information.
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 see the CLI Guide and Reference.
|
If you require additional information at this point you can refer to the following topics in Detailed Configuration Information: |
Before DB2 CLI and ODBC applications can successfully access a DB2 database from a Macintosh client, perform the following steps on the client system:
For more information see Configuring Database Connections.
The MacODBC driver manager uses the ODBC Preferences file or the ODBC Preferences PPC file to record information about the available drivers and data sources.
It is also possible to modify these files manually. Do not change any of the existing entries in the files.
[ODBC Data Sources] GLOBALDB=IBM ODBC DB2 for Macintosh SAMPLE=IBM ODBC DB2 for Macintosh [GLOBALDB] Driver=appl:ODBC$DB2DriverFunctionSet Description=My GLOBAL database [SAMPLE] Driver=appl:ODBC$DB2DriverFunctionSet Description=My SAMPLE database
[ODBC Data Sources] SAMPLE=IBM ODBC DB2 for PPC [SAMPLE] Driver=DB2ODBCDriverPPC Description=My SAMPLE database
For each data source listed in the [ODBC Data Source] section, there is a section that lists additional information about that data source. These are called the Data Source Specification sections.
Under the [ODBC DATA SOURCE] entry, add the following line:
where database_alias is the alias of the database cataloged in the database directory (the database name used by the Command Line Processor CONNECT TO statement).
[database_alias] Driver=appl:ODBC$DB2DriverFunctionSet
[database_alias] Driver=DB2ODBCDriverPPC
Where database_alias is the alias of the database cataloged in the database directory, and listed under the Data Source Specification section.
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.
See Binding Database Utilities for more information.
DB2 CLI can be configured further by using either the CCA or the DB2 Client Setup administration tool, whichever is applicable for your platform, or 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 as follows:
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 all the keywords and their usage, refer to Configuration Keyword Descriptions.
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.
Microsoft‘s 16-bit ODBC Driver Manager and Visigenic‘s ODBC Driver Manager use the odbc.ini file to record information about the available drivers and data sources. Visigenic‘s ODBC Driver Manager also uses the odbcinst.ini file on UNIX platforms. Although the necessary files are updated automatically by the tools on most platforms, users of ODBC on UNIX platforms will have to edit them manually. The file odbc.ini (and odbcinst.ini where required) are located:
It is also possible to modify this file manually. Do not change any of the existing entries in the file.
The following is an example odbc.ini file:
[ODBC Data Sources] MS Access Databases=Access Data (*.mdb) [MS Access Databases] Driver=D:\WINDOWS\SYSTEM\simba.dll FileType=RedISAM SingleUser=False UseSystemDB=False
The [ODBC Data Sources] section lists the name of each available data source and the description of the associated driver.
For each data source listed in the [ODBC Data Sources] section, there is a section that lists additional information about that data source. These are called the Data Source Specification sections.
database_alias=IBM DB2 ODBC DRIVER
where database_alias is the alias of the database cataloged in the database directory (the database name used by the command line processor CONNECT TO statement).
[database_alias] Driver=x:\windows\system\db2cliw.dll
Where:
The following shows the example file with the IBM data source entries added:
[ODBC Data Sources] MS Access Databases=Access Data (*.mdb) SAMPLE=IBM DB2 ODBC DRIVER [MS Access Databases] Driver=D:\WINDOWS\SYSTEM\simba.dll FileType=RedISAM SingleUser=False UseSystemDB=False [SAMPLE] Driver=D:\WINDOWS\SYSTEM\db2cliw.dll Description=Sample DB2 Client/Server database
Note: | If you are running the ODBC application under WIN-OS/2, specify the equivalent path \OS2\MDOS\WINOS2\SYSTEM in place of the \WINDOWS\SYSTEM path. |
标签:
原文地址:http://www.cnblogs.com/sthv/p/5959718.html