org.opencms.db
Class CmsDbPool

java.lang.Object
  extended by org.opencms.db.CmsDbPool

public final class CmsDbPool
extends java.lang.Object

Various methods to create DBCP pools.

Only JDBC Driver based pools are supported currently. JNDI DataSource based pools might be added probably later.

Please note: This class is subject to change in later versions. To obtain information about the connections, please use the CmsSqlManager.

Since:
6.0.0
Version:
$Revision: 1.52 $
Author:
Thomas Weckert

Field Summary
static java.lang.String DBCP_JDBC_URL_PREFIX
          This prefix is required to make the JDBC DriverManager return pooled DBCP connections.
static java.lang.String KEY_CONNECT_ATTEMTS
          Key for number of connection attempts.
static java.lang.String KEY_CONNECT_WAITS
          Key for connection waiting.
static java.lang.String KEY_DATABASE
          Prefix for database keys.
static java.lang.String KEY_DATABASE_NAME
          Key for the database name.
static java.lang.String KEY_DATABASE_POOL
          Key for the pool id.
static java.lang.String KEY_DATABASE_STATEMENTS
          Key for statement pooling.
static java.lang.String KEY_JDBC_DRIVER
          Key for jdbc driver.
static java.lang.String KEY_JDBC_URL
          Key for jdbc url.
static java.lang.String KEY_JDBC_URL_PARAMS
          Key for jdbc url params.
static java.lang.String KEY_MAX_ACTIVE
          Key for maximum active connections.
static java.lang.String KEY_MAX_IDLE
          Key for maximum idle connections.
static java.lang.String KEY_MAX_WAIT
          Key for maximum wait time.
static java.lang.String KEY_MIN_EVICTABLE_IDLE_TIME
          Key for minimum idle time before a connection is subject to an eviction test.
static java.lang.String KEY_MIN_IDLE
          Key for minimum number of connections kept open.
static java.lang.String KEY_NUM_TESTS_PER_EVICTION_RUN
          Key for number of tested connections per run.
static java.lang.String KEY_PASSWORD
          Key for database password.
static java.lang.String KEY_POOL_DEFAULT
          Key for default.
static java.lang.String KEY_POOL_URL
          Key for pool url.
static java.lang.String KEY_POOL_USER
          Key for pool user.
static java.lang.String KEY_POOL_VFS
          Key for vfs pool.
static java.lang.String KEY_POOLING
          Key for pooling flag.
static java.lang.String KEY_TEST_ON_BORROW
          Key for test on borrow flag.
static java.lang.String KEY_TEST_QUERY
          Key for test query.
static java.lang.String KEY_TEST_WHILE_IDLE
          Key for test while idle flag.
static java.lang.String KEY_TIME_BETWEEN_EVICTION_RUNS
          Key for time between two eviction runs.
static java.lang.String KEY_USERNAME
          Key for user name.
static java.lang.String KEY_WHEN_EXHAUSTED_ACTION
          Key for "when pool exhausted" action.
static java.lang.String OPENCMS_DEFAULT_POOL_NAME
          The name of the opencms default pool.
static java.lang.String OPENCMS_DEFAULT_POOL_URL
          The default OpenCms JDBC pool URL.
static java.lang.String OPENCMS_URL_PREFIX
          The prefix used for opencms JDBC pools.
 
Method Summary
static org.apache.commons.dbcp.PoolingDriver createDriverManagerConnectionPool(java.util.Map configuration, java.lang.String key)
          Creates a JDBC DriverManager based DBCP connection pool.
static java.lang.String getDbPoolName(java.util.Map configuration, java.lang.String key)
          Returns the database pool name for a given configuration key.
static java.util.List getDbPoolUrls(org.apache.commons.collections.ExtendedProperties configuration)
          Returns a list of available database pool names.
static java.lang.String getDefaultDbPoolName()
          Returns the name of the default database connection pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBCP_JDBC_URL_PREFIX

public static final java.lang.String DBCP_JDBC_URL_PREFIX
This prefix is required to make the JDBC DriverManager return pooled DBCP connections.

See Also:
Constant Field Values

KEY_CONNECT_ATTEMTS

public static final java.lang.String KEY_CONNECT_ATTEMTS
Key for number of connection attempts.

See Also:
Constant Field Values

KEY_CONNECT_WAITS

public static final java.lang.String KEY_CONNECT_WAITS
Key for connection waiting.

See Also:
Constant Field Values

KEY_DATABASE

public static final java.lang.String KEY_DATABASE
Prefix for database keys.

See Also:
Constant Field Values

KEY_DATABASE_NAME

public static final java.lang.String KEY_DATABASE_NAME
Key for the database name.

See Also:
Constant Field Values

KEY_DATABASE_POOL

public static final java.lang.String KEY_DATABASE_POOL
Key for the pool id.

See Also:
Constant Field Values

KEY_DATABASE_STATEMENTS

public static final java.lang.String KEY_DATABASE_STATEMENTS
Key for statement pooling.

See Also:
Constant Field Values

KEY_JDBC_DRIVER

public static final java.lang.String KEY_JDBC_DRIVER
Key for jdbc driver.

See Also:
Constant Field Values

KEY_JDBC_URL

public static final java.lang.String KEY_JDBC_URL
Key for jdbc url.

See Also:
Constant Field Values

KEY_JDBC_URL_PARAMS

public static final java.lang.String KEY_JDBC_URL_PARAMS
Key for jdbc url params.

See Also:
Constant Field Values

KEY_MAX_ACTIVE

public static final java.lang.String KEY_MAX_ACTIVE
Key for maximum active connections.

See Also:
Constant Field Values

KEY_MAX_IDLE

public static final java.lang.String KEY_MAX_IDLE
Key for maximum idle connections.

See Also:
Constant Field Values

KEY_MAX_WAIT

public static final java.lang.String KEY_MAX_WAIT
Key for maximum wait time.

See Also:
Constant Field Values

KEY_MIN_EVICTABLE_IDLE_TIME

public static final java.lang.String KEY_MIN_EVICTABLE_IDLE_TIME
Key for minimum idle time before a connection is subject to an eviction test.

See Also:
Constant Field Values

KEY_MIN_IDLE

public static final java.lang.String KEY_MIN_IDLE
Key for minimum number of connections kept open.

See Also:
Constant Field Values

KEY_NUM_TESTS_PER_EVICTION_RUN

public static final java.lang.String KEY_NUM_TESTS_PER_EVICTION_RUN
Key for number of tested connections per run.

See Also:
Constant Field Values

KEY_PASSWORD

public static final java.lang.String KEY_PASSWORD
Key for database password.

See Also:
Constant Field Values

KEY_POOL_DEFAULT

public static final java.lang.String KEY_POOL_DEFAULT
Key for default.

See Also:
Constant Field Values

KEY_POOL_URL

public static final java.lang.String KEY_POOL_URL
Key for pool url.

See Also:
Constant Field Values

KEY_POOL_USER

public static final java.lang.String KEY_POOL_USER
Key for pool user.

See Also:
Constant Field Values

KEY_POOL_VFS

public static final java.lang.String KEY_POOL_VFS
Key for vfs pool.

See Also:
Constant Field Values

KEY_POOLING

public static final java.lang.String KEY_POOLING
Key for pooling flag.

See Also:
Constant Field Values

KEY_TEST_ON_BORROW

public static final java.lang.String KEY_TEST_ON_BORROW
Key for test on borrow flag.

See Also:
Constant Field Values

KEY_TEST_QUERY

public static final java.lang.String KEY_TEST_QUERY
Key for test query.

See Also:
Constant Field Values

KEY_TEST_WHILE_IDLE

public static final java.lang.String KEY_TEST_WHILE_IDLE
Key for test while idle flag.

See Also:
Constant Field Values

KEY_TIME_BETWEEN_EVICTION_RUNS

public static final java.lang.String KEY_TIME_BETWEEN_EVICTION_RUNS
Key for time between two eviction runs.

See Also:
Constant Field Values

KEY_USERNAME

public static final java.lang.String KEY_USERNAME
Key for user name.

See Also:
Constant Field Values

KEY_WHEN_EXHAUSTED_ACTION

public static final java.lang.String KEY_WHEN_EXHAUSTED_ACTION
Key for "when pool exhausted" action.

See Also:
Constant Field Values

OPENCMS_DEFAULT_POOL_NAME

public static final java.lang.String OPENCMS_DEFAULT_POOL_NAME
The name of the opencms default pool.

See Also:
Constant Field Values

OPENCMS_DEFAULT_POOL_URL

public static final java.lang.String OPENCMS_DEFAULT_POOL_URL
The default OpenCms JDBC pool URL.

See Also:
Constant Field Values

OPENCMS_URL_PREFIX

public static final java.lang.String OPENCMS_URL_PREFIX
The prefix used for opencms JDBC pools.

See Also:
Constant Field Values
Method Detail

createDriverManagerConnectionPool

public static org.apache.commons.dbcp.PoolingDriver createDriverManagerConnectionPool(java.util.Map configuration,
                                                                                      java.lang.String key)
                                                                               throws java.lang.Exception
Creates a JDBC DriverManager based DBCP connection pool.

Parameters:
configuration - the configuration (opencms.properties)
key - the key of the database pool in the configuration
Returns:
String the URL to access the created DBCP pool
Throws:
java.lang.Exception - if the pool could not be initialized

getDbPoolName

public static java.lang.String getDbPoolName(java.util.Map configuration,
                                             java.lang.String key)
Returns the database pool name for a given configuration key.

Parameters:
configuration - the configuration
key - a db pool configuration key
Returns:
the database pool name

getDbPoolUrls

public static java.util.List getDbPoolUrls(org.apache.commons.collections.ExtendedProperties configuration)
Returns a list of available database pool names.

Parameters:
configuration - the configuration to read the pool names from
Returns:
a list of database pool names

getDefaultDbPoolName

public static java.lang.String getDefaultDbPoolName()
Returns the name of the default database connection pool.

Returns:
the name of the default database connection pool