Implementing Connection Callbacks
To implement connection callbacks:
1. Create a derived class (for example, UserConnCallbackImp) from the base class RWDBConnCallbackImp.
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 systemHandle() to access the database-specific connection handle. Accessor methods databaseCallback() and environmentHandle() provide access to the RWDBDatabaseCallback associated with the RWDBDatabase object that produced this RWDBConnection and to the environment handle associated with the RWDBDatabase object. The callback methods can use the status() and setError() methods to set any errors and invoke the error handler.
3. Provide an instance of the derived class in the method RWDBDatabase::connection() to produce an RWDBConnection object that will call the callback methods. Each RWDBConnection object may be associated with different connection callback classes to have different behavior. For example:
 
dbase.connection(RWDBCONNCALLBACK(UserConnCallbackImp));
The instance of the derived class must be produced using the macro RWDBCONNCALLBACK. This ensures that a new instance of the connection callback gets produced for each RWDBConnection produced. 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:
RWDBCONNCALLBACK(UserConnCallbackImp(10, "xyz")).
4. To avoid passing an instance of the connection callback to every new connection, you can produce the instance of the connection callback by redefining the producer method produceConnCallback() in RWDBDatabaseCallbackImp class.
The connection callback will be produced for all implicit and explicit connections produced from that RWDBDatabase with which the database callback is associated. For example:
 
RWDBConnCallback
UserDatabaseCallbackImp::produceConnCallback() {
return RWDBCONNCALLBACK(UserConnCallbackImp));
}