This section describes the arguments used to build a connect string to a DB2 database.
In order for a DBTools.h++ application to interact with a database, an RWDBDatabase instance must be created by calling:
RWDBManager::database(accessLib, serverName, userName, passWord, databaseName);
All arguments are of type RWCString. The parameters are used to build a connect string that is passed to the DB2 CLI function SQLDriverConnect(). The string is of the form:
DSN=serverName; PWD=passWord; UID=userName
Here is an explanation of each argument:
accessLib: If your DBTools.h++ access library for DB2 CLI is compiled as a shared library, provide the name of the library. See the DBTools.h++ Build Guide, for information about naming conventions. If you are using a static library, supply the string "DB2CLI". This is a required parameter.
serverName: Supply the name or alias-name of the database to which you wish to connect, as found using the DB2 Command Line Processor. This is a required parameter.
userName: Supply a login of a valid user.
passWord: Supply the password for the user specified by userName.
databaseName: This parameter is not applicable and should be left blank, as shown in the following examples.
Here are several examples of connecting to a server called INHOUSE on a DB2 Common Server.
In the first example, both the user name and the password are given to provide the highest level of security. Notice that the accessLib is defined as DB2CLI, indicating that the application must be linked with the static version of the access library:
RWDBManager::database("DB2CLI", "INHOUSE", "cratchitt","scrooge","");
The second example shows how to open the same database from a Windows NT application. In this case, the accessLib is defined as "db24d.dll", indicating that the application will dynamically load (DLL) the access library at runtime:
RWDBManager::database("db24d.dll", "INHOUSE", "cratchitt", "scrooge", "");
The final example demonstrates how to open the same database again using the access library as a Unix shared library at runtime:
RWDBManager::database("libdb24d.so", "INHOUSE", "cratchitt", "scrooge", "");
The library name shown is for Solaris and AIX.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.