9 Connection Pool Manager : DataDirect Connection Pool Manager Interfaces

DataDirect Connection Pool Manager Interfaces
This section describes the methods used by the DataDirect Connection Pool Manager interfaces: PooledConnectionDataSourceFactory, PooledConnectionDataSource, and ConnectionPoolMonitor.
PooledConnectionDataSourceFactory
The PooledConnectionDataSourceFactory interface is used to create a PooledConnectionDataSource object from a Reference object that is stored in a naming or directory service. These methods are typically invoked by a JNDI service provider; they are not usually invoked by a user application.
static Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env)
Creates a PooledConnectionDataSource object from a Reference object that is stored in a naming or directory service. This is an implementation of the method of the same name defined in the javax.naming.spi.ObjectFactory interface. Refer to the Javadoc for this interface for a description.
PooledConnectionDataSource
The PooledConnectionDataSource interface is used to create a PooledConnectionDataSource object for use with the DataDirect Connection Pool Manager.
Closes the connection pool. All physical connections in the pool are closed. Any subsequent connection request re-initializes the connection pool.
Connection getConnection(String user, String password)
Obtains a physical connection from the connection pool, where user is the user requesting the connection and password is the password for the connection.
Returns the JNDI name that is used to look up the DataDirect DataSource object referenced by this PooledConnectionDataSource.
Returns the description of this PooledConnectionDataSource.
Returns the value of the initial pool size, which is the number of physical connections created when the connection pool is initialized.
Returns the value of the login timeout, which is the time allowed for the database login to be validated.
Returns the writer to which the Pool Manager sends trace information about its activities.
Returns the value of the maximum idle time, which is the time a physical connection can remain idle in the connection pool before it is removed from the connection pool.
Returns the value of the maximum pool size. See “Understanding the Maximum Pool Size” for more information about how the Pool Manager implements the maximum pool size.
Returns the value of the maximum pool size behavior. See “Understanding the Maximum Pool Size” for more information about how the Pool Manager implements the maximum pool size.
Returns the value of the minimum pool size, which is the minimum number of idle connections to be kept in the pool.
Returns the value of the property cycle, which specifies how often the pool maintenance thread wakes up and checks the connection pool.
Obtains a javax.naming.Reference object for this PooledConnectionDataSource. The Reference object contains all the state information needed to recreate an instance of this data source using the PooledConnectionDataSourceFactory object. This method is typically called by a JNDI service provider when this PooledConnectionDataSource is bound to a JNDI naming service.
Returns an array of Connection Pool Monitors, one for each connection pool managed by the Pool Manager.
Returns the name of the Connection Pool Monitor for the connection pool specified by name. If a pool with the specified name cannot be found, this method returns null. The connection pool name has the form:
jndi_name-user_id
where jndi_name is the name used for the JNDI lookup of the driver DataSource object from which the pooled connection was obtained and user_id is the user ID used to establish the connections contained in the pool.
The following example shows how to return the Connection Pool Monitor for the connection pool that is bound to the JNDI lookup name jdbc/SQLServerPool and connections established by user test04.
DataSource ds = (DataSource) ctx.lookup("jdbc/SQLServerPool");
Connection con = ds.getConnection
   ("test04", "test04");
ConnectionPoolMonitor monitor = PooledConnectionDataSource.getMonitor
   ("jdbc/SQLServerPool-test04");
Determines whether tracing is enabled. If enabled, tracing information is sent to the PrintWriter that is passed to the setLogWriter() method or the standard output System.out if the setLogWriter() method is not called.
Sets the JNDI name, which is used to look up the driver DataSource object referenced by this PooledConnectionDataSource. The driver DataSource object bound to this PooleConnectionDataSource, specified by dataSourceName, is not persisted. Any changes made to the PooledConnectionDataSource bound to the specified driver DataSource object affect this PooledConnectionDataSource.
void setDataSourceName(String dataSourceName, ConnectionPoolDataSource dataSource)
Sets the JNDI name associated with this PooledConnectionDataSource, specified by dataSourceName, and the driver DataSource object, specified by dataSource, referenced by this PooledConnectionDataSource.
The driver DataSource object, specified by dataSource, is persisted with this PooledConnectionDataSource. Changes made to the specified driver DataSource object after this PooledConnectionDataSource is persisted do not affect this PooledConnectionDataSource.
void setDataSourceName(String dataSourceName, Context ctx)
Sets the JNDI name, specified by dataSourceName, and context, specified by ctx, to be used to look up the driver DataSource referenced by this PooledConnectionDataSource.
The JNDI name, specified by dataSourceName, and context, specified by ctx, are used to look up a driver DataSource object. The driver DataSource object is persisted with this PooledConnectionDataSource. Changes made to the driver DataSource after this PooledConnectionDataSource is persisted do not affect this PooledConnectionDataSource.
Sets the description of the PooledConnectionDataSource, where description is the description.
Sets the value of the initial pool size, which is the number of connections created when the connection pool is initialized.
Sets the value of the login timeout, where i is the login timeout, which is the time allowed for the database login to be validated.
If set to true, the timestamp is logged when DataDirect Spy logging is enabled. If set to false, the timestamp is not logged.
If set to true, the thread name is logged when DataDirect Spy logging is enabled. If set to false, the thread name is not logged.
Sets the writer, where printWriter is the writer to which the stream will be printed.
Sets the value of the maximum idle time, which is the time a connection can remain idle in the connection pool before it is closed and removed from the pool.
Sets the value of the maximum pool size, which is the maximum number of connections for each user allowed in the pool. See “Understanding the Maximum Pool Size” for more information about how the Pool Manager implements the maximum pool size. In addition, see “Using Reauthentication with the Pool Manager”.
Sets the value of the maximum pool size behavior, which is either softCap or hardCap.
If setMaxPoolSizeBehavior(softCap), the number of active connections may exceed the maximum pool size, but the number of idle connections in the connection pool for each user cannot exceed this limit. If a user requests a connection and an idle connection is unavailable, the Pool Manager creates a new connection for that user. When the connection is no longer needed, it is returned to the pool. If the number of idle connections exceeds the maximum pool size, the Pool Manager closes idle connections to enforce the maximum pool size limit. This is the default behavior.
If setMaxPoolSizeBehavior(hardCap), the total number of active and idle connections cannot exceed the maximum pool size. Instead of creating a new connection for a connection request if an idle connection is unavailable, the Pool Manager queues the connection request until a connection is available or the request times out. This behavior is useful if your database server has memory limitations or is licensed for only a specific number of connections.The timeout is set using the LoginTimeout connection property. If the connection request times out, the driver throws an exception.
See “Understanding the Maximum Pool Size” for more information about how the Pool Manager implements the maximum pool size.
Sets the value of the minimum pool size, which is the minimum number of idle connections to be kept in the connection pool.
Sets the value of the property cycle, which specifies how often the pool maintenance thread wakes up and checks the connection pool.
Enables and disables reauthentication for the Pool Manager. To enable reauthentication, use setReauthentication(enable). To disable reauthentication, use setReauthentication(disable). See “Using Reauthentication with the Pool Manager” for more information.
Enables or disables tracing. If set to true, tracing is enabled; if false, it is disabled. If enabled, tracing information is sent to the PrintWriter that is passed to the setLogWriter() method or the standard output System.out if the setLogWriter() method is not called.
ConnectionPoolMonitor
The ConnectionPoolMonitor interface is used to return information that is useful for monitoring the status of your connection pools.
Returns the name of the connection pool associated with the monitor. The connection pool name has the form:
jndi_name-user_id
where jndi_name is the name used for the JNDI lookup of the PooledConnectionDataSource object from which the pooled connection was obtained and user_id is the user ID used to establish the connections contained in the pool.
Returns the number of connections that have been checked out of the pool and are currently in use.
Returns the initial size of the connection pool (the number of available connections in the pool when the pool was first created).
Returns the maximum number of available connection in the connection pool. If the number of available connections exceeds this value, the Pool Manager removes one or multiple available connections from the pool.
Returns the minimum number of available connections in the connection pool. When the number of available connections is lower than this value, the Pool Manager creates additional connections and makes them available.
Returns the current size of the connection pool, which is the total of active connections and available connections.