Implementing Database Callbacks
To implement a database callback:
1. Create a derived class (for example, UserDatabaseCallbackImp) from the base class RWDBDatabaseCallbackImp.
2. Redefine the necessary callback methods in the derived class. All the callback methods in the base class are defined as empty methods. The redefined methods can use the accessor method environmentHandle() to access the database specific environment/context handles. They can use the status() and setError() methods to set any errors and invoke the error handler.
3. Optionally, redefine the producer method produceConnCallback() to produce a RWDBConnCallback object to be associated with every new connection produced from this RWDBDatabase object this callback will be associated with. Note, however, this method will not be used if a custom RWDBConnCallback object is supplied in the RWDBDatabase::connection() call.
4. Provide an instance of the derived class in the method RWDBManager::database() to produce an RWDBDatabase object that will call the callback methods. Each RWDBDatabase object has its own database callback instance, thus allowing different behaviors for different RWDBDatabase objects.
 
RWDBManager::database(
"accesslib", "servername", "username",
"password", "databasename",
RWDBDATABASECALLBACK(UserDatabaseCallbackImp));
The instance of the derived class must be produced using the macro RWDBDATABASECALLBACK. This ensures that a new instance of the database callback gets produced for each RWDBDatabase object. Just providing the name of the derived callback class, will create its instance using the default constructor. To use a different constructor, pass the arguments along with it. For example:
RWDBDATABASECALLBACK(UserDatabaseCallbackImp(100, "abc")).