Databases and Connections
This section describes the arguments required to create an instance of
RWDBDatabase for the DB Access Module for Sybase.
In order for a SourcePro DB application to open and use the connections required for interacting with a database, an
RWDBDatabase instance must be created by calling:
RWDBManager::database(accessLib, serverName, userName,
passWord, databaseName, propertyString);
All arguments are of type
RWCString. For Sybase Open Client Client-Library, you must provide the following arguments:
accessLib: If you are using DLLs or shared libraries, provide their names. If you are using a static library, supply the string
SYBASE_CT. See the guide
Building Your Applications for information about naming conventions.
serverName: Supply the name of the server to which you are connecting, as found in your local interfaces or
sql.ini file in the Sybase client installation.
userName: Supply the server login name for a valid user.
passWord: Supply the password for the user.
NOTE: You can instead provide a password using the callback API, which may provide more security. For more information, see Chapter 10, “Callbacks” in the DB Interface Module User’s Guide.
databaseName: You can optionally supply the name of a server database to use. If this parameter is not supplied, the default database of the specified user is used.
propertyString: You can optionally supply any of the connection properties,
CS_APPNAME, CS_HOSTNAME, CS_PACKETSIZE or
CS_SEC_ENCRYPTION, in the form
property=value, separated by semicolons. These connection properties, described in the Sybase Open Client Client-Library documentation, are set when obtaining a connection.
Here are three examples of opening a database on a specific server, INHOUSE.
The first example opens a specific database, ACCOUNTING. A user name and a password are specified. Notice that the accessLib is defined as SYBASE_CT, indicating that the application must be linked with the static version of the Access Module:
RWDBManager::database("SYBASE_CT", "INHOUSE",
"cratchitt", "scrooge", "ACCOUNTING");
The second example shows opening the same database from a Microsoft Windows application. In this case, accessLib is defined as ctl<ver>12d.dll, indicating that the application will dynamically load (DLL) the Access Module at runtime. The connection property CS_HOSTNAME is also supplied:
RWDBManager::database("ctl<ver>12d.dll", "INHOUSE", "cratchitt",
"scrooge", "ACCOUNTING", "CS_HOSTNAME=Dickens");
The final example shows opening a user’s default database, that is, the database assigned to the user by the database administrator. In this case, an application will use the Access Module as a UNIX shared library at runtime:
RWDBManager::database("libctl<ver>12d.so", "INHOUSE",
"cratchitt", "scrooge", "");