org.apache.commons.dbcp.cpdsadapter
Class DriverAdapterCPDS
- ConnectionPoolDataSource, ObjectFactory, Referenceable, Serializable
public class DriverAdapterCPDS
An adapter for jdbc drivers that do not include an implementation
of
javax.sql.ConnectionPoolDataSource
, but still include a
java.sql.DriverManager
implementation.
ConnectionPoolDataSource
s are not used within general
applications. They are used by
DataSource
implementations
that pool
Connection
s, such as
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.
Version:
- John D. McNally
- Serialized Form
String | getDescription() - Get the value of description.
|
String | getDriver() - Get the driver classname.
|
PrintWriter | getLogWriter() - Get the log writer for this data source.
|
int | getLoginTimeout() - Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database.
|
int | getMaxActive() - The maximum number of active statements that can be allocated from
this pool at the same time, or zero for no limit.
|
int | getMaxIdle() - The maximum number of statements that can remain idle in the
pool, without extra ones being released, or zero for no limit.
|
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).
|
int | getNumTestsPerEvictionRun() - Returns the number of statements to examine during each run of the
idle object evictor thread (if any).
|
Object | getObjectInstance(Object refObj, Name name, Context context, Hashtable env) - implements ObjectFactory to create an instance of this class
|
String | getPassword() - Get the value of password for the default user.
|
PooledConnection | getPooledConnection() - Attempt to establish a database connection using the default
user and password.
|
PooledConnection | getPooledConnection(java.lang.String username, java.lang.String password) - Attempt to establish a database connection.
|
Reference | getReference() -
Referenceable implementation.
|
int | getTimeBetweenEvictionRunsMillis() - Returns the number of milliseconds to sleep between runs of the
idle object evictor thread.
|
String | getUrl() - Get the value of url used to locate the database for this datasource.
|
String | getUser() - Get the value of default user (login or username).
|
boolean | isPoolPreparedStatements() - Flag to toggle the pooling of
PreparedStatement s
|
void | setDescription(java.lang.String v) - Set the value of description.
|
void | setDriver(java.lang.String v) - Set the driver classname.
|
void | setLogWriter(PrintWriter out) - Set the log writer for this data source.
|
void | setLoginTimeout(int seconds) - Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database.
|
void | setMaxActive(int maxActive) - The maximum number of active statements that can be allocated from
this pool at the same time, or zero for no limit.
|
void | setMaxIdle(int maxIdle) - The maximum number of statements that can remain idle in the
pool, without extra ones being released, or zero for no limit.
|
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).
|
void | setNumTestsPerEvictionRun(int numTestsPerEvictionRun) - Sets the number of statements to examine during each run of the
idle object evictor thread (if any).
|
void | setPassword(java.lang.String v) - Set the value of password for the default user.
|
void | setPoolPreparedStatements(boolean v) - Flag to toggle the pooling of
PreparedStatement s
|
void | setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) - Sets the number of milliseconds to sleep between runs of the
idle object evictor thread.
|
void | setUrl(java.lang.String v) - Set the value of url used to locate the database for this datasource.
|
void | setUser(java.lang.String v) - Set the value of default user (login or username).
|
DriverAdapterCPDS
public DriverAdapterCPDS()
Default no-arg constructor for Serialization
getDescription
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.
- value of description.
getDriver
public String getDriver()
Get the driver classname.
- value of driver.
getLogWriter
public PrintWriter getLogWriter()
Get the log writer for this data source. NOT USED.
getLoginTimeout
public int getLoginTimeout()
Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database. NOT USED.
getMaxActive
public int getMaxActive()
The maximum number of active statements that can be allocated from
this pool at the same time, or zero for no limit.
getMaxIdle
public int getMaxIdle()
The maximum number of statements that can remain idle in the
pool, without extra ones being released, or zero for no limit.
getMinEvictableIdleTimeMillis
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
getNumTestsPerEvictionRun
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
getPassword
public String getPassword()
Get the value of password for the default user.
- value of password.
getPooledConnection
public PooledConnection getPooledConnection()
throws SQLException
Attempt to establish a database connection using the default
user and password.
getPooledConnection
public PooledConnection getPooledConnection(java.lang.String username,
java.lang.String password)
throws SQLException
Attempt to establish a database connection.
getTimeBetweenEvictionRunsMillis
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
getUrl
public String getUrl()
Get the value of url used to locate the database for this datasource.
- value of url.
getUser
public String getUser()
Get the value of default user (login or username).
- value of user.
isPoolPreparedStatements
public boolean isPoolPreparedStatements()
Flag to toggle the pooling of PreparedStatement
s
- value of poolPreparedStatements.
setDescription
public void setDescription(java.lang.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.
v
- Value to assign to description.
setDriver
public void setDriver(java.lang.String v)
throws ClassNotFoundException
Set the driver classname. Setting the driver classname cause the
driver to be registered with the DriverManager.
v
- Value to assign to driver.
setLogWriter
public void setLogWriter(PrintWriter out)
Set the log writer for this data source. NOT USED.
setLoginTimeout
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.
setMaxActive
public void setMaxActive(int maxActive)
The maximum number of active statements that can be allocated from
this pool at the same time, or zero for no limit.
setMaxIdle
public void setMaxIdle(int maxIdle)
The maximum number of statements that can remain idle in the
pool, without extra ones being released, or zero for no limit.
setMinEvictableIdleTimeMillis
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
setNumTestsPerEvictionRun
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
setPassword
public void setPassword(java.lang.String v)
Set the value of password for the default user.
v
- Value to assign to password.
setPoolPreparedStatements
public void setPoolPreparedStatements(boolean v)
Flag to toggle the pooling of PreparedStatement
s
v
- true to pool statements.
setTimeBetweenEvictionRunsMillis
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
setUrl
public void setUrl(java.lang.String v)
Set the value of url used to locate the database for this datasource.
v
- Value to assign to url.
setUser
public void setUser(java.lang.String v)
Set the value of default user (login or username).
v
- Value to assign to user.
Copyright © 2001-2003 Apache Software Foundation. Documenation generated February 28 2005.