com.ibm.u2.jdbcx
Class UniJDBCConnectionPoolDataSource

java.lang.Object
  |
  +--com.ibm.u2.jdbcx.UniJDBCCoreDataSource
        |
        +--com.ibm.u2.jdbcx.UniJDBCConnectionPoolDataSource
All Implemented Interfaces:
javax.sql.ConnectionPoolDataSource, javax.naming.Referenceable, java.io.Serializable

public class UniJDBCConnectionPoolDataSource
extends UniJDBCCoreDataSource
implements javax.sql.ConnectionPoolDataSource, javax.naming.Referenceable

UniJDBCConnectionPoolDataSource is the IBM Universe/Unidata implemenation of javax.sql.ConnectionPoolDataSource. This class is embedded in the datasource that implements connection pooling.

See Also:
DataSource, ConnectionPoolDataSource, UniJDBCCoreDataSource, Serialized Form

Fields inherited from class com.ibm.u2.jdbcx.UniJDBCCoreDataSource
DSProperties, mMsgFactory, password, user, value
 
Constructor Summary
UniJDBCConnectionPoolDataSource()
          Contructor.
 
Method Summary
protected  boolean checkIsDirect()
          checkIsDirect -- check if the protocol is DirectProtocol once per CPDS
protected  void checkMaxConnections()
          enforce IBM_CPM_MAX_CONNECTIONS This is NOT synchronized; you may have to do so if necessary.
protected  int getConnectionCount()
          get the count of connections allocated by the "DB server".
 int getInitialPoolSize()
          IBM_CPM_INIT_POOLSIZE = initialPoolSize JDBC3.0 compliance
 int getMaxIdleTime()
          IBM_CPM_AGELIMIT = maxIdleTime JDBC3.0 compliance
 int getMaxPoolSize()
          IBM_CPM_MAX_POOLSIZE = maxPoolSize JDBC3.0 compliance
 int getMaxStatements()
          getmaxStatements: Not implemented for JDBC 2.30
 int getMinPoolSize()
          IBM_CPM_MIN_POOLSIZE = minPoolSize JDBC3.0 compliance
 javax.sql.PooledConnection getPooledConnection()
          Attempt to establish a database connection.
 javax.sql.PooledConnection getPooledConnection(java.lang.String luser, java.lang.String lpassword)
          Attempt to establish a database connection.
 javax.sql.PooledConnection getPooledConnection(java.lang.String luser, java.lang.String lpassword, com.ibm.u2.jdbcx.UniJDBCConnectionEventListener listener)
          Attempt to establish a database connection.
 int getPropertyCycle()
           
 javax.naming.Reference getReference()
          Make a reference to this UniJDBCConnectionPooledDataSource.
protected  java.lang.reflect.Constructor getReUsableCons()
          getReUsableCons -- get the directReUsableConstructor
 long getUniJDBCCPMAgeLimit()
          Gets the life span of a connection in the Pool .
 int getUniJDBCCPMInitPoolSize()
          gets the initial number of connections to preallocate for the Pool Default is 0.
 int getUniJDBCCPMMaxConnections()
          gets the limit for the maximum number of connections Default is -1, meaning no limit restriction.
 int getUniJDBCCPMMaxPoolSize()
          gets the high water mark for the Pool.
 long getUniJDBCCPMMinAgeLimit()
          Gets the ageLimit for connections under the minimum level Default is -1, means it lives indefinitely 0, means it lives as long as the other free connections
 int getUniJDBCCPMMinPoolSize()
          gets the minimum connections to maintain in the Pool.
 long getUniJDBCCPMServiceInterval()
          Gets the Pool service interval in milliseconds.
protected  void incConnectionCount(int amount)
          increment/decrement the count of connections from the server.
 void setInitialPoolSize(int init)
          IBM_CPM_INIT_POOLSIZE = initialPoolSize JDBC3.0 compliance
 void setMaxIdleTime(int ageLimit)
          IBM_CPM_AGELIMIT = maxIdleTime JDBC3.0 compliance
 void setMaxPoolSize(int max)
          IBM_CPM_MAX_POOLSIZE = maxPoolSize JDBC3.0 compliance
 void setMaxStatements(int limit)
          maxStatements - This is a parameter for statement pooling and is not implemented for JDBC 2.30
 void setMinPoolSize(int min)
          IBM_CPM_MIN_POOLSIZE = minPoolSize JDBC3.0 compliance
 void setPropertyCycle(int cyc)
           
protected  void setReUsableCons(java.lang.reflect.Constructor cons)
          setReUsableCons -- set the directReUsableConstructor
 void setUniJDBCCPMAgeLimit(long ageLimit)
          Sets the property IBM_CPM_AGELIMIT The value limits the life of a connection in the pool.
 void setUniJDBCCPMInitPoolSize(int init)
          Sets the property IBM_CPM_INIT_POOLSIZE The value is the initial number of connections to preallocate for the Pool.
 void setUniJDBCCPMMaxConnections(int limit)
          Sets the property IBM_CPM_MAX_CONNECTIONS The value is the maximum limit to the total number of Server connections for the Connection Pool Datasource.
 void setUniJDBCCPMMaxPoolSize(int max)
          Sets the property IBM_CPM_MAX_POOLSIZE The value is the high-water mark for the Pool.
 void setUniJDBCCPMMinAgeLimit(long ageLimit)
          Sets the property IBM_CPM_MIN_AGELIMIT The value is length of time in seconds in which connections under the minimum level are maintained.
 void setUniJDBCCPMMinPoolSize(int min)
          Sets the property IBM_CPM_MIN_POOLSIZE The value is the minimum number of connections to maintain in the free Pool.
 void setUniJDBCCPMServiceInterval(long interval)
          Sets the property IBM_CPM_SERVICE_INTERVAL The value is service interval in milliseconds in which the Pool Service thread will pause in between operations.
 
Methods inherited from class com.ibm.u2.jdbcx.UniJDBCCoreDataSource
addProp, getAccount, getCountry, getDataSourceName, getDBMSType, getDescription, getDsProperties, getLanguage, getLoginTimeout, getLogWriter, getMsgFactory, getNetworkType, getODBCConfigURL, getODBCDSName, getPassword, getProp, getServerHost, getServerPort, getService, getTraceFile, getTraceLevel, getUser, readProperties, removeProperty, setAccount, setCountry, setDataSourceName, setDBMSType, setDescription, setLanguage, setLoginTimeout, setLogWriter, setNetworkType, setODBCConfigURL, setODBCDSName, setPassword, setServerHost, setServerPort, setService, setTraceFile, setTraceLevel, setUser, writeProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.sql.ConnectionPoolDataSource
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
 

Constructor Detail

UniJDBCConnectionPoolDataSource

public UniJDBCConnectionPoolDataSource()
Contructor. Allocates an empty UniJDBCConnectionPoolDataSource object
Method Detail

setReUsableCons

protected void setReUsableCons(java.lang.reflect.Constructor cons)
setReUsableCons -- set the directReUsableConstructor

getReUsableCons

protected java.lang.reflect.Constructor getReUsableCons()
getReUsableCons -- get the directReUsableConstructor

getPooledConnection

public javax.sql.PooledConnection getPooledConnection()
                                               throws java.sql.SQLException

Attempt to establish a database connection.

Specified by:
getPooledConnection in interface javax.sql.ConnectionPoolDataSource
Returns:
a Connection to the database
Throws:
java.sql.SQLException - if a database-access error occurs. NEVER USED

getPooledConnection

public javax.sql.PooledConnection getPooledConnection(java.lang.String luser,
                                                      java.lang.String lpassword)
                                               throws java.sql.SQLException

Attempt to establish a database connection.

Specified by:
getPooledConnection in interface javax.sql.ConnectionPoolDataSource
Parameters:
user - the database user on whose behalf the Connection is being made
password - the user's password
Returns:
a Connection to the database
Throws:
java.sql.SQLException - if a database-access error occurs. DOES NOT APPEAR TO BE USED

getPooledConnection

public javax.sql.PooledConnection getPooledConnection(java.lang.String luser,
                                                      java.lang.String lpassword,
                                                      com.ibm.u2.jdbcx.UniJDBCConnectionEventListener listener)
                                               throws java.sql.SQLException

Attempt to establish a database connection.

Parameters:
user - the database user on whose behalf the Connection is being made
password - the user's password
listener - the event listener.
Returns:
a Connection to the database
Throws:
java.sql.SQLException - if a database-access error occurs.

checkMaxConnections

protected void checkMaxConnections()
                            throws java.sql.SQLException

enforce IBM_CPM_MAX_CONNECTIONS This is NOT synchronized; you may have to do so if necessary.

Throws:
java.sql.SQLException - if

incConnectionCount

protected void incConnectionCount(int amount)

increment/decrement the count of connections from the server. This is NOT synchronized; you have to do so if necessary.

Parameters:
amount - is the number to add or subtract

getConnectionCount

protected int getConnectionCount()

get the count of connections allocated by the "DB server". Note: be aware that multiple client threads may be running asynchronously to get or close connections! You will have to block them if necessary.


getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException

Make a reference to this UniJDBCConnectionPooledDataSource. (see similar comments in UniJDBCDataSource)

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
a Reference object to UniJDBCConnectionPooledDataSource.
Throws:
javax.naming.NamingException - if error occurs in getting the reference.

setUniJDBCCPMMaxConnections

public void setUniJDBCCPMMaxConnections(int limit)
Sets the property IBM_CPM_MAX_CONNECTIONS The value is the maximum limit to the total number of Server connections for the Connection Pool Datasource. This total is the sum of the connections in the free Pool, plus those that are in-use and not closed by the application.
Parameters:
limit - is the maximum connections allowed for the CPDS .

setMaxStatements

public void setMaxStatements(int limit)
                      throws java.sql.SQLException
maxStatements - This is a parameter for statement pooling and is not implemented for JDBC 2.30

getUniJDBCCPMMaxConnections

public int getUniJDBCCPMMaxConnections()
gets the limit for the maximum number of connections Default is -1, meaning no limit restriction.

getMaxStatements

public int getMaxStatements()
                     throws java.sql.SQLException
getmaxStatements: Not implemented for JDBC 2.30

setUniJDBCCPMInitPoolSize

public void setUniJDBCCPMInitPoolSize(int init)
Sets the property IBM_CPM_INIT_POOLSIZE The value is the initial number of connections to preallocate for the Pool.
Parameters:
init - is the number of initial connections

setInitialPoolSize

public void setInitialPoolSize(int init)
IBM_CPM_INIT_POOLSIZE = initialPoolSize JDBC3.0 compliance

getUniJDBCCPMInitPoolSize

public int getUniJDBCCPMInitPoolSize()
gets the initial number of connections to preallocate for the Pool Default is 0.

getInitialPoolSize

public int getInitialPoolSize()
IBM_CPM_INIT_POOLSIZE = initialPoolSize JDBC3.0 compliance

setUniJDBCCPMMaxPoolSize

public void setUniJDBCCPMMaxPoolSize(int max)
Sets the property IBM_CPM_MAX_POOLSIZE The value is the high-water mark for the Pool. When the number of connections exceed this number, any closed connection will be returned to server instead of being recycled.
Parameters:
max - is the maximum connections to keep in the Pool.

setMaxPoolSize

public void setMaxPoolSize(int max)
IBM_CPM_MAX_POOLSIZE = maxPoolSize JDBC3.0 compliance

getUniJDBCCPMMaxPoolSize

public int getUniJDBCCPMMaxPoolSize()
gets the high water mark for the Pool. Default is 100.

getMaxPoolSize

public int getMaxPoolSize()
IBM_CPM_MAX_POOLSIZE = maxPoolSize JDBC3.0 compliance

setUniJDBCCPMMinPoolSize

public void setUniJDBCCPMMinPoolSize(int min)
Sets the property IBM_CPM_MIN_POOLSIZE The value is the minimum number of connections to maintain in the free Pool. When the number of connections fall below this minumum, a background the Pool Service thread will fill it up at a specified rate (see UniJDBCCPMServiceInterval).
Parameters:
min - is the minimum connections to maintain in the Pool.

setMinPoolSize

public void setMinPoolSize(int min)
IBM_CPM_MIN_POOLSIZE = minPoolSize JDBC3.0 compliance

getUniJDBCCPMMinPoolSize

public int getUniJDBCCPMMinPoolSize()
gets the minimum connections to maintain in the Pool. Default is 0, means the Pool can be empty.

getMinPoolSize

public int getMinPoolSize()
IBM_CPM_MIN_POOLSIZE = minPoolSize JDBC3.0 compliance

setUniJDBCCPMMinAgeLimit

public void setUniJDBCCPMMinAgeLimit(long ageLimit)
Sets the property IBM_CPM_MIN_AGELIMIT The value is length of time in seconds in which connections under the minimum level are maintained.
Parameters:
ageLimit - is the time in seconds.

getUniJDBCCPMMinAgeLimit

public long getUniJDBCCPMMinAgeLimit()
Gets the ageLimit for connections under the minimum level Default is -1, means it lives indefinitely 0, means it lives as long as the other free connections

setUniJDBCCPMAgeLimit

public void setUniJDBCCPMAgeLimit(long ageLimit)
Sets the property IBM_CPM_AGELIMIT The value limits the life of a connection in the pool.
Parameters:
ageLimit - is the time in seconds.

setMaxIdleTime

public void setMaxIdleTime(int ageLimit)
IBM_CPM_AGELIMIT = maxIdleTime JDBC3.0 compliance

getUniJDBCCPMAgeLimit

public long getUniJDBCCPMAgeLimit()
Gets the life span of a connection in the Pool . Default is -1, means indefinitely

getMaxIdleTime

public int getMaxIdleTime()
IBM_CPM_AGELIMIT = maxIdleTime JDBC3.0 compliance

setPropertyCycle

public void setPropertyCycle(int cyc)
                      throws java.sql.SQLException

getPropertyCycle

public int getPropertyCycle()
                     throws java.sql.SQLException

setUniJDBCCPMServiceInterval

public void setUniJDBCCPMServiceInterval(long interval)
Sets the property IBM_CPM_SERVICE_INTERVAL The value is service interval in milliseconds in which the Pool Service thread will pause in between operations. This serves to reduce CPU and resource contention.
Parameters:
interval - the service interval in milliseconds.

getUniJDBCCPMServiceInterval

public long getUniJDBCCPMServiceInterval()
Gets the Pool service interval in milliseconds. Default is 100 milliseconds.

checkIsDirect

protected boolean checkIsDirect()
checkIsDirect -- check if the protocol is DirectProtocol once per CPDS