This section describes the arguments used to create an instance of RWDBDatabase for the DB Access module of PostgreSQL. In order for a SourcePro DB 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. These parameters are used to build a connection string which is passed to the libpq function PQconnectdb.
The arguments you must provide to RWDBManager::database() are:
accessLib: If your DB Access Module for PostgreSQL is compiled as a DLL or shared library, provide the name of the DLL or shared library. See the document Building Your Applications for information about naming conventions. If you are using a static library, supply the string "POSTGRESQL".
serverName: Supply the name of the PostgreSQL host. Or, for direct control of connection parameters, pass a full connect string of the form required by PQconnectdb(); for example:
For example:
"host = somehost user = someUser dbname = someDBname" |
In this case, the string is passed to PQconnectdb() without modification, and the userName, passWord, and databaseName parameters are ignored.
userName: Supply a login of a valid user.
passWord: Supply the password for the login specified by userName.
databaseName: Supply the name of the PostgreSQL database to use.
Here are two examples of opening a database.
Notice that the accessLib is defined as POSTGRESQL, indicating that the application will use the static version of the access library and must be linked with it:
RWDBDatabase aDB = RWDBManager::database ("POSTGRESQL", "myHost", "cratchitt","scrooge", "SALES"); |
The second example shows opening the same database from a Windows application. In this case, the accessLib is defined as pgs8015d.dll, indicating that the application will dynamically load the Access Module at runtime:
RWDBDatabase aDB = RWDBManager::database ("pgs8015d.dll", "INHOUSE", "cratchitt", "scrooge", "SALES"); |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.