This section describes the arguments used to build a connect string to a MySQL database. 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, connectOptions); |
All arguments are of type RWCString. These parameters are passed to the MySQL C API function mysql_real_connect().
The arguments you must provide to RWDBManager::database() are:
accessLib: If your DB Access Module for MySQL 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 "MYSQL".
serverName: Supply the name or the IP address of the MySQL server to which you are connecting.
userName: Supply a valid MySQL login ID.
passWord: Supply the password for the user specified by userName.
databaseName: Supply a valid database name. The databaseName is required due to a restriction from mysql_real_connect().
connectOptions: If the port number is other than the default, pass a string with the syntax PORT=XXXX where XXXX is the port number to use to connect to the server. For example: PORT=3667
Here are two examples of opening a database.
The first example accesses a MySQL Server database using a shared build of the Access Module. A user name and password are provided. Notice that accessLib is defined as "mys8015d.dll", indicating that the application will dynamically load the Access Module at runtime:
RWDBDatabase aDB = RWDBManager::database ("mys8015d.dll", "MySQL-Server", "cratchitt","scrooge", ""); |
The second example accesses MySQL Server using a static build of the Access Module. Notice that accessLib is defined as "MYSQL", indicating that the application will use the static version of the Access Module:
RWDBDatabase aDB = RWDBManager::database ("MYSQL", "192.168.1.100","cratchitt","scrooge", ""); |
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.
Contact Rogue Wave about documentation or support issues.