
Module: DB Interface Module Group: Callback Classes
RWDBDatabaseCallbackImpRWDBReference
|
environmentHandle() postEnvAllocate() preEnvAllocate() |
preEnvDestroy() produceConnCallback() RWDBDatabaseCallbackImp() |
serverType() setError() status() |
#include <rw/db/dbasecbi.h>
class MyDBaseCallbackImp : public RWDBDatabaseCallbackImp {
public:
// PostEnvAllocate callback
virtual void postEnvAllocate();
// Connection callback producer
virtual RWDBConnCallback produceConnCallback();
};
RWDBDatabase dBase =
RWDBManager::database("accessLib", "Servername",
"Username", "PassWord",
"DatabaseName",
RWDBDATABASECALLBACK(MyDBaseCallbackImp) );
RWDBDatabaseCallbackImp is an implementation class and is reference counted.
It is the abstract base class for implementing database callbacks. You will need to derive from this class to implement your custom database callbacks.
This class provides three database callback methods preEnvAllocate(), postEnvAllocate() and preEnvDestroy(). It also provides a connection callback producer method produceConnCallback(). Please refer to the DB Interface Module User's Guide and applicable DB Access Module User's Guide for more information on these methods. You will need to redefine the methods to implement database callbacks and/or produce connection callback instances.
RWDBDatabaseCallbackImp();
The default protected constructor.
virtual void preEnvAllocate();
This callback is invoked just before the allocation of database- specific environment/context handle. It is defined as a no-op. To implement preEnvAllocate callback, you will need to derive from this class and redefine this method.
virtual void postEnvAllocate();
This callback is invoked after the allocation of database specific-environment/context handle. It is defined as a no-op. To implement postEnvAllocate callback, you will need to derive from this class and redefine this method.
virtual void preEnvDestroy();
This callback is invoked just before the deallocation of environment/context handle. It is defined as a no-op. To implement preEnvDestroy callback, you will need to derive from this class and redefine this method. This callback will typically be called from the destructor of the RWDBDatabase object and, hence, you should refrain from throwing an exception
virtual RWDBConnCallback produceConnCallback();
This method must produce a new instance of a connection callback implementation. This method is invoked by an RWDBDatabase object while producing a new RWDBConnection object. The RWDBConnCallback object produced by this method will be associated with the new RWDBConnection produced.
This method produces an uninitialized connection callback object with all connection callbacks as no-ops. To produce custom connection callbacks, you will need to derive from this class and redefine this method to produce new instances of connection callbacks using the macro RWDBCONNCALLBACK(CALLBACK).
For example:
RWDBConnCallback
MyDBaseCallbackImp::produceConnCallback()
{
return RWDBCONNCALLBACK(MyConnCallbackImp);
}
NOTE -- Redefining this method to return multiple types of connection callback objects might affect your use of the connection pool, as the connection pool might contain connections associated with different connection callback objects.
RWDBEnvironmentHandle* environmentHandle() const;
Returns a pointer to the RWDBEnvironmentHandle of the RWDBDatabase object to which self is associated. If self is not associated with any RWDBDatabase object, returns 0.
RWCString serverType() const;
Returns the serverType of the RWDBDatabase object to which self is associated. If self is not associated with any RWDBDatabase object, returns empty string
RWDBStatus status() const;
Returns the current status of self.
void
setError(RWDBStatus::ErrorCode code,
const RWCString& message,
const RWCString& vendorMessage1 =
RWCString(),
const RWCString& vendorMessage2 =
RWCString(),
long vendorError1 = 0,
long vendorError2 = 0,
bool isTerminal
= false,
bool invokeErrorHandler
= true,
bool invalidateDatabase
= false);
Sets an error on self. Optionally, invalidates the RWDBDatabase object to which self is associated.
Parameters code, message, vendorMessage1, vendorMessage2, vendorError1, vendorError2 and isTerminal are RWDBStatus attributes used to set the error on self's RWDBStatus object.
The parameter invokeErrorHandler indicates if the associated error handler should be invoked.
The parameter invalidateDatabase indicates if the RWDBDatabase object to which self is associtaed should be invalidated. If invalidated, the RWDBDatabase object will have an error code of RWDBStatus::applicationError.
© 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.