Module: DB Interface Module Group: Database Classes
Does not inherit
#include <rw/db/dbmgr.h> RWDBDatabase myDbase = RWDBManager::database("myDbaseType", "myDbaseServerName", "myLoginName", "myPassword", "myDbaseName");
There is a single, global RWDBManager in charge of producing RWDBDatabases typed according to the application's request. It mediates access to database servers, abstracting details of access to vendor-supplied libraries, including any dynamic loading and linking. The RWDBManager, through its database() method, is responsible for filling requests for database implementations of a particular type. To do so, it maintains a set of database types for which it is able to produce an implementation.
Associated with each database type is a method that produces the implementation. This method may reside in a dynamically-linked library, or may be statically linked with a specialized object. In the former case, the method is identified by a conventional name, rwdbNewDatabaseImp, with any ambiguity alleviated by the containing library. In the latter case, each method must be uniquely named, as in rwdbNewSybaseDatabaseImp, for example. The association between method names and database types is made at link time via static initialization.
When presented with a request for a particular type of database implementation, the RWDBManager consults its set of known implementations. If no entry is found, and the operating environment supports dynamic linking, a search is made for a dynamically-linked library (DLL) whose name matches the requested type. If a DLL is found, it is loaded, the conventionally-named method is located, and the association is added to the set of implementations of the RWDBManager. Once an entry is located, its method is invoked to obtain an implementation of the requested type, a connection is established, and the result is returned to the caller. If no entry is found, the object returned to the caller has a status of RWDBStatus::notFound.
static RWDBDatabase database(const RWCString& serverType, const RWCString& serverName, const RWCString& userName, const RWCString& password, const RWCString& databaseName, const RWDBDatabaseCallback& databasecb = RWDBDatabaseCallback()); static RWDBDatabase database(const RWCString& serverType, const RWCString& serverName, const RWCString& userName, const RWCString& passWord, const RWCString& databaseName, const RWCString& propertyString, const RWDBDatabaseCallback& databasecb = RWDBDatabaseCallback());
Produces an RWDBDatabase. The first argument lets the DB Interface Module identify the kind of database being requested. The remaining arguments except the last are used to establish a session with the requested database server. Since the details of logging into a database vary widely among vendors, the actual values supplied for the various parameters vary according to accessLib. Your DB Access Module guide explains the values you must supply to obtain RWDBDatabases from your library. The last argument provides an instance of the RWDBDatabaseCallback to be associated with the produced RWDBDatabase object.
static bool emptyStringIsNull();
Retrieves the setting of this flag.
static void emptyStringIsNull(bool n);
Allows an application to specify whether the RWDBDatabase instance produced by the call to RWDBManager::database treats empty strings as NULL values.
The default setting is false, which means that empty strings are handled as the database vendor normally handles them. If this flag is set to true, empty strings are treated as NULL values by SourcePro DB.
Note that the SQL92 standard does not specify if empty strings are NULL values or not. Various database vendors treat empty strings differently. For example, Oracle considers an empty string to be the same as a NULL, while other database vendors do not. Consider the following example:
RWCString empty; RWDBInserter ins=aTbl.inserter(); ins<<empty; ins.execute();
If the setting is true, the SQL generated is like:
insert into sometable values(NULL)
Otherwise, it is like:
insert into sometable values(`')
However, these two SQL statements mean the same to Oracle. Setting the flag to true has no effect.
static RWDBStatus::ErrorHandler errorHandler() const;
Retrieves the error handler currently installed in the RWDBManager, if any.
static RWDBStatus::ErrorHandler setErrorHandler(RWDBStatus::ErrorHandler handler);
Installs handler as the error handler for the RWDBManager. The supplied handler is inherited by all RWDBDatabase instances created by the RWDBManager. By default, the RWDBManager error handler does nothing; this method overrides the default. The errorHandler is declared as a typedef within the scope of RWDBStatus:
typedef void (*ErrorHandler)(const RWDBStatus&);
static RWCString version();
Returns a string that identifies the version of the DB Interface Module in which self resides. Note: this method identifies the version of the DB Interface Module, while RWDBDatabase::version() identifies the version of a DB Access Module.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.