Index
Purpose:
DKDatastorePool is a class that manages the datastore connection
pool. A DKDatastorePool object can only handle the connection pool for
one datastore type. You can use getConnection(userid, password) and
returnConnection(datastore) for the connected datastore with no session
ID. And you can use getConnection(userid, password, sessionId) and
returnConnection(DKDatastoreSession) for the connected datastore with session
ID. With the session ID you will get the same datastore back, but it is
not guaranteed if you leave it in the pool too long because it will
timeout. To guarantee the same connection information, after a
connected datastore is created, you cannot change the set information
including datastore name, connection string, configuration string,
maxPoolSize, minPoolsize and time out.
Class summary:
class DKEXPORT DKDatastorePool
{
public:
DKDatastorePool(const char* dsType, const char* factoryDLLName);
virtual ~DKDatastorePool();
virtual DKString getDatastoreName() const;
virtual void setDatastoreName(const char* aDSName);
virtual DKString getConnectString() const;
virtual void setConnectString(const char* connectString);
virtual DKString getConfigurationString() const;
virtual void setConfigurationString(const char* configString);
virtual int getMaxPoolSize() const;
virtual void setMaxPoolSize(int poolSize);
virtual int getMinPoolSize() const;
virtual void setMinPoolSize(int poolSize);
virtual int getTimeOut() const;
virtual void setTimeOut(int timeOut);
virtual dkDatastore* getConnection(const char* userId,
const char* passwd);
virtual DKDatastoreSession* getConnection(const char* userId,
const char* passwd,
long aSessionId);
virtual void returnConnection(dkDatastore* ds);
virtual void returnConnection(DKDatastoreSession* aDsSession);
virtual void returnConnection(DKDatastoreSession* aDsSession);
virtual void initConnections(const char* userId,
const char* passwd,
int initSize);
virtual void removeConnection(dkDatastore* ds);
virtual void removeConnection(DKDatastoreSession* aDsSession);
virtual void clearConnections();
virtual DKString datastoreType() const;
virtual void setValidate(DKBoolean aValidate);
DKBoolean getValidate();
};
Members:
-
-
- Constructor
- Create the datastore pool for a specific datastore type.
valid dsType: (case sensitive);
DB2, DD, DES, DJ, DL, ICM, IP, ODBC, OD, V4, IC
alid factoryDLLName:
NT: cmbxxfac816, cmbxxfac816d
AIX: libcmbxxfac815.so, libcmbxxfac815d.so (lower case)
xx can be db2, dd, des, dj, dl, icm, ip, odbc, od, v4, ic
DKDatastorePool(const char* dsType, const char* factoryDLLName);
Destructor
virtual ~DKDatastorePool();
- Member functions
-
- getDatastoreName
- Gets the name of the datastore object. Usually it represents a
datastore source's server name.
virtual DKString getDatastoreName() const;
- setDatastoreName
- Sets the name of the datastore object. Usually it represents a
datastore source's server name. Once the datastore has been
created and connected, you can not set this to a different name.
virtual void setDatastoreName(const char* aDSName);
- getConnectString
- Gets the connection string that is used to provide additional connection
options.
virtual DKString getConnectString() const;
- setConnectString
- Sets the connection string that is used to provide additional connection
options. Once a datastore has been created and connected, you can not
set this to a different string.
virtual void setConnectString(const char* connectString);
- getConfigurationString
- Gets the configuration string which supplies the specific initialization
parameters for datastore.
virtual DKString getConfigurationString() const;
- setConfigurationString
- Sets the configuration string which supplies the specific initialization
parameters for datastore. for example:
CC2MIMEURL=value The URL for the file containing the content class to mime
type mapping. CC2MIMEFILE=value The name of the file containing the
content class to mime type mapping. This parameter is ignored if the
CC2MIMEURL is specified. Once a datastore has been created and
connected, you can not set this to a different configuration string.
virtual void setConfigurationString(const char* configString);
- getMaxPoolSize
- Gets the maximum number of connections that the pool should
contain. 0(zero) indicates no maximum size (unlimited).
virtual int getMaxPoolSize() const;
- setMaxPoolSize
- Sets the maximum number of connections that the pool should
contain. 0(zero) indicates no maximum size (unlimited). Once the
datastore has been created & connected, you can not set this to a
different number.
virtual void setMaxPoolSize(int poolSize);
- getMinPoolSize
- Gets the minimum number of connections that the pool should keep.
0(zero) indicates the connections should be created as needed.
virtual int getMinPoolSize() const;
- setMinPoolSize
- Sets the minimum number of connections that the pool should keep.
0(zero) indicates the connections should be created as needed. Once the
datastore has been created & connected, you can not set this to a
different number.
virtual void setMinPoolSize(int poolSize);
- getTimeOut
- Gets the number of minutes that a datastore connection should remain
unused in the pool before the datastore is disconnect & destroyed.
0(zero) indicates no limit.
virtual int getTimeOut() const;
- setTimeOut
- Sets the number of minutes that a datastore connection should remain
unused in the pool before the datastore is disconnect & destroyed.
0(zero) indicates no limit.
virtual void setTimeOut(int timeOut);
- getConnection
- Gets a connected datastore with no session Id from the pool This will
search the connected datastore with no session Id, if no matched one it will
create a new one.
virtual dkDatastore* getConnection(const char* userId, const char* passwd);
- getConnection
- Gets a connected datastore with sessionId from the pool and returns a
DKDatastaoreSession object that contains the connected datastore and session
ID. The sequence to get the connected datastore is:
if aSessionId <= 0
It will return a DKDatastoreSession object that contains a new connected
datastore with the next avaliable session ID. When the maximum pool is
reached, it will search the available datastore with no session ID and return
DKDatastoreSession containing datastore and the next available session
ID. An application must call DKDatastoreSession getId() to obtain the
session ID.
If aSessionId > 0, the following search sequence is performed:
- Search the available datastore with the matching session ID. If
found, returns datastore and the same session ID.
- Search the available datastore with no session ID. If found,
returns DKDatastoreSession containing the datastore and assign the next
available session ID to it.
- Create a new connected datastore with the next avaliable session ID,
returns DKDatastoreSession containing the datastore and session ID.
- Search the available datastore with the different session ID (oldest in
queue). If found, returns DKDatastoreSession containing the datastore
and that different session ID.
The application should call DKDatastoreSession getDatastore() to obtain
the dkDatastore and getId() to check the session ID.
virtual DKDatastoreSession* getConnection(const char* userId, const char* passwd, long aSessionId);
- returnConnection
- Returns a connected datastore with no session Id to the pool.
virtual void returnConnection(dkDatastore* ds);
- returnConnection
- Returns a connected datastore with session Id to the pool.
virtual void returnConnection(DKDatastoreSession* aDsSession);
- removeConnection
- Removes a datastore with no session ID from the pool, this is so that the
application can remove the bad datastore from the pool.
virtual void removeConnection(dkDatastore* ds);
- removeConnection
- Removes a datastore with session ID from the pool, this is so that the
application can remove the bad datastore from pool.
virtual void removeConnection(DKDatastoreSession* aDsSession);
- initConnections
- Initialize number of connections and store them in the pool. This
is only for the datastore with no session Id.
virtual void initConnections(const char* userId, const char* passwd, int initSize);
- clearConnections
- Clears this object instance including all the setted data and the
connections in the free pool. If any conneciton is in use it will throw
an exception.
virtual void clearConnections();
- datastoreType
- Gets the datastore type for this datastore pool objects A instance of
DKDatastorePool can only handle one datastore type.
virtual DKString datastoreType() const;
- setValidate
- Sets the validate flag. When this flag is true, the available
datastore in the free pool will be validated again with the database
connection before returning to the caller of getConnection methods.
This slows down system performance. The purpose of this method is to
check if the DB2 server is down or running.
virtual void setValidate(DKBoolean aValidate);
- getValidate
- Gets the validate flag. If the validate flag is true, it will
validate the connection to the datastore whenever the getConnection() is
called.
virtual DKBoolean getValidate();
(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.