Save This Page
Home » commons-dbcp-1.2.2-src » org.apache.commons » dbcp » cpdsadapter » [javadoc | source]
org.apache.commons.dbcp.cpdsadapter
public class: DriverAdapterCPDS [javadoc | source]
java.lang.Object
   org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS

All Implemented Interfaces:
    Referenceable, ConnectionPoolDataSource, Serializable, ObjectFactory

An adapter for jdbc drivers that do not include an implementation of javax.sql.ConnectionPoolDataSource , but still include a java.sql.DriverManager implementation. ConnectionPoolDataSources are not used within general applications. They are used by DataSource implementations that pool Connections, such as org.apache.commons.dbcp.datasources.SharedPoolDataSource . A J2EE container will normally provide some method of initializing the ConnectionPoolDataSource whose attributes are presented as bean getters/setters and then deploying it via JNDI. It is then available as a source of physical connections to the database, when the pooling DataSource needs to create a new physical connection.

Although normally used within a JNDI environment, the DriverAdapterCPDS can be instantiated and initialized as any bean and then attached directly to a pooling DataSource. Jdbc2PoolDataSource can use the ConnectionPoolDataSource with or without the use of JNDI.

The DriverAdapterCPDS also provides PreparedStatement pooling which is not generally available in jbdc2 ConnectionPoolDataSource implementation, but is addressed within the jdbc3 specification. The PreparedStatement pool in DriverAdapterCPDS has been in the dbcp package for some time, but it has not undergone extensive testing in the configuration used here. It should be considered experimental and can be toggled with the poolPreparedStatements attribute.

The package documentation contains an example using catalina and JNDI. The datasources package documentation shows how to use DriverAdapterCPDS as a source for Jdbc2PoolDataSource without the use of JNDI.

Constructor:
 public DriverAdapterCPDS() 
Method from org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS Summary:
getDescription,   getDriver,   getLogWriter,   getLoginTimeout,   getMaxActive,   getMaxIdle,   getMaxPreparedStatements,   getMinEvictableIdleTimeMillis,   getNumTestsPerEvictionRun,   getObjectInstance,   getPassword,   getPooledConnection,   getPooledConnection,   getReference,   getTimeBetweenEvictionRunsMillis,   getUrl,   getUser,   isPoolPreparedStatements,   setDescription,   setDriver,   setLogWriter,   setLoginTimeout,   setMaxActive,   setMaxIdle,   setMaxPreparedStatements,   setMinEvictableIdleTimeMillis,   setNumTestsPerEvictionRun,   setPassword,   setPoolPreparedStatements,   setTimeBetweenEvictionRunsMillis,   setUrl,   setUser
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS Detail:
 public String getDescription() 
    Get the value of description. This property is here for use by the code which will deploy this datasource. It is not used internally.
 public String getDriver() 
    Get the driver classname.
 public PrintWriter getLogWriter() 
    Get the log writer for this data source. NOT USED.
 public int getLoginTimeout() 
    Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. NOT USED.
 public int getMaxActive() 
    The maximum number of active statements that can be allocated from this pool at the same time, or non-positive for no limit.
 public int getMaxIdle() 
    The maximum number of statements that can remain idle in the pool, without extra ones being released, or negative for no limit.
 public int getMaxPreparedStatements() 
    Returns the maximun number of prepared statements.
 public int getMinEvictableIdleTimeMillis() 
    Returns the minimum amount of time a statement may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any). *see #setMinEvictableIdleTimeMillis *see #setTimeBetweenEvictionRunsMillis
 public int getNumTestsPerEvictionRun() 
    Returns the number of statements to examine during each run of the idle object evictor thread (if any). *see #setNumTestsPerEvictionRun *see #setTimeBetweenEvictionRunsMillis
 public Object getObjectInstance(Object refObj,
    Name name,
    Context context,
    Hashtable env) throws Exception 
    implements ObjectFactory to create an instance of this class
 public String getPassword() 
    Get the value of password for the default user.
 public PooledConnection getPooledConnection() throws SQLException 
    Attempt to establish a database connection using the default user and password.
 public PooledConnection getPooledConnection(String username,
    String password) throws SQLException 
    Attempt to establish a database connection.
 public Reference getReference() throws NamingException 
    Referenceable implementation.
 public int getTimeBetweenEvictionRunsMillis() 
    Returns the number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run. *see #setTimeBetweenEvictionRunsMillis
 public String getUrl() 
    Get the value of url used to locate the database for this datasource.
 public String getUser() 
    Get the value of default user (login or username).
 public boolean isPoolPreparedStatements() 
    Flag to toggle the pooling of PreparedStatements
 public  void setDescription(String v) 
    Set the value of description. This property is here for use by the code which will deploy this datasource. It is not used internally.
 public  void setDriver(String v) throws ClassNotFoundException 
    Set the driver classname. Setting the driver classname cause the driver to be registered with the DriverManager.
 public  void setLogWriter(PrintWriter out) 
    Set the log writer for this data source. NOT USED.
 public  void setLoginTimeout(int seconds) 
    Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. NOT USED.
 public  void setMaxActive(int maxActive) 
    The maximum number of active statements that can be allocated from this pool at the same time, or non-positive for no limit.
 public  void setMaxIdle(int maxIdle) 
    The maximum number of statements that can remain idle in the pool, without extra ones being released, or negative for no limit.
 public  void setMaxPreparedStatements(int maxPreparedStatements) 
    Sets the maximum number of prepared statements.
 public  void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) 
    Sets the minimum amount of time a statement may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any). When non-positive, no objects will be evicted from the pool due to idle time alone. *see #getMinEvictableIdleTimeMillis *see #setTimeBetweenEvictionRunsMillis
 public  void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) 
    Sets the number of statements to examine during each run of the idle object evictor thread (if any).

    When a negative value is supplied, ceil({*link #numIdle})/abs({*link #getNumTestsPerEvictionRun}) tests will be run. I.e., when the value is -n, roughly one nth of the idle objects will be tested per run. *see #getNumTestsPerEvictionRun *see #setTimeBetweenEvictionRunsMillis

 public  void setPassword(String v) 
    Set the value of password for the default user.
 public  void setPoolPreparedStatements(boolean v) 
    Flag to toggle the pooling of PreparedStatements
 public  void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) 
    Sets the number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run. *see #getTimeBetweenEvictionRunsMillis
 public  void setUrl(String v) 
    Set the value of url used to locate the database for this datasource.
 public  void setUser(String v) 
    Set the value of default user (login or username).