org.apache.james.util.dbcp
Class JdbcDataSource
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.james.util.dbcp.JdbcDataSource
- All Implemented Interfaces:
- org.apache.avalon.excalibur.datasource.DataSourceComponent, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.thread.ThreadSafe
public class JdbcDataSource
- extends org.apache.avalon.framework.logger.AbstractLogEnabled
- implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.excalibur.datasource.DataSourceComponent
This is a reliable DataSource implementation, based on the pooling logic provided by DBCP and the configuration found in
Avalon's excalibur code.
This uses the normal java.sql.Connection
object and
java.sql.DriverManager
. The Configuration is like this:
<jdbc>
<pool-controller min="5" max="10" connection-class="my.overrided.ConnectionClass">
<keep-alive>select 1</keep-alive>
</pool-controller>
<driver>com.database.jdbc.JdbcDriver</driver>
<dburl>jdbc:driver://host/mydb</dburl>
<user>username</user>
<password>password</password>
</jdbc>
These configuration settings are available:
- driver - The class name of the JDBC driver
- dburl - The JDBC URL for this connection
- user - The username to use for this connection
- password - The password to use for this connection
- keep-alive - The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row.
- max - The maximum number of active connections allowed in the pool. 0 means no limit. (default 2)
- max_idle - The maximum number of idle connections. 0 means no limit. (default 0)
- initial_size - The initial number of connections that are created when the pool is started. (default 0)
- min_idle - The minimum number of active connections that can remain idle in the pool, without extra ones being created, or zero to create none. (default 0)
- max_wait - The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely. (default -1)
- testOnBorrow - The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. (default true)
- testOnReturn - The indication of whether objects will be validated before being returned to the pool. (default false)
- testWhileIdle - The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool. (default false)
- timeBetweenEvictionRunsMillis - 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. (default -1)
- numTestsPerEvictionRun - The number of objects to examine during each run of the idle object evictor thread (if any). (default 3)
- minEvictableIdleTimeMillis - The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any). (default 1000 * 60 * 30)
- Version:
- CVS $Revision: 494012 $
Fields inherited from interface org.apache.avalon.excalibur.datasource.DataSourceComponent |
ROLE |
Method Summary |
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
|
void |
dispose()
|
java.sql.Connection |
getConnection()
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JdbcDataSource
public JdbcDataSource()
configure
public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
- Specified by:
configure
in interface org.apache.avalon.framework.configuration.Configurable
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException
- See Also:
Configurable.configure(Configuration)
dispose
public void dispose()
- Specified by:
dispose
in interface org.apache.avalon.framework.activity.Disposable
- See Also:
org.apache.avalon.framework.configuration.Configurable#dispose()
getConnection
public java.sql.Connection getConnection()
throws java.sql.SQLException
- Specified by:
getConnection
in interface org.apache.avalon.excalibur.datasource.DataSourceComponent
- Throws:
java.sql.SQLException
Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.