org.opencms.db
Class CmsDbPool

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

public final class CmsDbPool
extends 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

Field Summary
static String DBCP_JDBC_URL_PREFIX
          This prefix is required to make the JDBC DriverManager return pooled DBCP connections.
static String KEY_CONNECT_ATTEMTS
          Key for number of connection attempts.
static String KEY_CONNECT_WAITS
          Key for connection waiting.
static String KEY_DATABASE
          Prefix for database keys.
static String KEY_DATABASE_NAME
          Key for the database name.
static String KEY_DATABASE_POOL
          Key for the pool id.
static String KEY_DATABASE_STATEMENTS
          Key for statement pooling.
static String KEY_ENTITY_MANAGER_POOL_SIZE
          Key for the entity manager pool size.
static String KEY_JDBC_DRIVER
          Key for jdbc driver.
static String KEY_JDBC_URL
          Key for jdbc url.
static String KEY_JDBC_URL_PARAMS
          Key for jdbc url params.
static String KEY_MAX_ACTIVE
          Key for maximum active connections.
static String KEY_MAX_IDLE
          Key for maximum idle connections.
static String KEY_MAX_WAIT
          Key for maximum wait time.
static String KEY_MIN_EVICTABLE_IDLE_TIME
          Key for minimum idle time before a connection is subject to an eviction test.
static String KEY_MIN_IDLE
          Key for minimum number of connections kept open.
static String KEY_NUM_TESTS_PER_EVICTION_RUN
          Key for number of tested connections per run.
static String KEY_PASSWORD
          Key for database password.
static String KEY_POOL_DEFAULT
          Key for default.
static String KEY_POOL_URL
          Key for pool url.
static String KEY_POOL_USER
          Key for pool user.
static String KEY_POOL_VFS
          Key for vfs pool.
static String KEY_POOLING
          Key for pooling flag.
static String KEY_TEST_ON_BORROW
          Key for test on borrow flag.
static String KEY_TEST_QUERY
          Key for test query.
static String KEY_TEST_WHILE_IDLE
          Key for test while idle flag.
static String KEY_TIME_BETWEEN_EVICTION_RUNS
          Key for time between two eviction runs.
static String KEY_USERNAME
          Key for user name.
static String KEY_WHEN_EXHAUSTED_ACTION
          Key for "when pool exhausted" action.
static String OPENCMS_DEFAULT_POOL_NAME
          The name of the opencms default pool.
static String OPENCMS_DEFAULT_POOL_URL
          The default OpenCms JDBC pool URL.
static String OPENCMS_URL_PREFIX
          The prefix used for opencms JDBC pools.
 
Method Summary
static org.apache.commons.dbcp.PoolingDriver createDriverManagerConnectionPool(CmsParameterConfiguration config, String key)
          Creates a JDBC DriverManager based DBCP connection pool.
static String getDbPoolName(CmsParameterConfiguration configuration, String key)
          Returns the database pool name for a given configuration key.
static List<String> getDbPoolUrls(CmsParameterConfiguration configuration)
          Returns a list of available database pool names.
static 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 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 String KEY_CONNECT_ATTEMTS
Key for number of connection attempts.

See Also:
Constant Field Values

KEY_CONNECT_WAITS

public static final String KEY_CONNECT_WAITS
Key for connection waiting.

See Also:
Constant Field Values

KEY_DATABASE

public static final String KEY_DATABASE
Prefix for database keys.

See Also:
Constant Field Values

KEY_DATABASE_NAME

public static final String KEY_DATABASE_NAME
Key for the database name.

See Also:
Constant Field Values

KEY_DATABASE_POOL

public static final String KEY_DATABASE_POOL
Key for the pool id.

See Also:
Constant Field Values

KEY_DATABASE_STATEMENTS

public static final String KEY_DATABASE_STATEMENTS
Key for statement pooling.

See Also:
Constant Field Values

KEY_ENTITY_MANAGER_POOL_SIZE

public static final String KEY_ENTITY_MANAGER_POOL_SIZE
Key for the entity manager pool size.

See Also:
Constant Field Values

KEY_JDBC_DRIVER

public static final String KEY_JDBC_DRIVER
Key for jdbc driver.

See Also:
Constant Field Values

KEY_JDBC_URL

public static final String KEY_JDBC_URL
Key for jdbc url.

See Also:
Constant Field Values

KEY_JDBC_URL_PARAMS

public static final String KEY_JDBC_URL_PARAMS
Key for jdbc url params.

See Also:
Constant Field Values

KEY_MAX_ACTIVE

public static final String KEY_MAX_ACTIVE
Key for maximum active connections.

See Also:
Constant Field Values

KEY_MAX_IDLE

public static final String KEY_MAX_IDLE
Key for maximum idle connections.

See Also:
Constant Field Values

KEY_MAX_WAIT

public static final String KEY_MAX_WAIT
Key for maximum wait time.

See Also:
Constant Field Values

KEY_MIN_EVICTABLE_IDLE_TIME

public static final 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 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 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 String KEY_PASSWORD
Key for database password.

See Also:
Constant Field Values

KEY_POOL_DEFAULT

public static final String KEY_POOL_DEFAULT
Key for default.

See Also:
Constant Field Values

KEY_POOL_URL

public static final String KEY_POOL_URL
Key for pool url.

See Also:
Constant Field Values

KEY_POOL_USER

public static final String KEY_POOL_USER
Key for pool user.

See Also:
Constant Field Values

KEY_POOL_VFS

public static final String KEY_POOL_VFS
Key for vfs pool.

See Also:
Constant Field Values

KEY_POOLING

public static final String KEY_POOLING
Key for pooling flag.

See Also:
Constant Field Values

KEY_TEST_ON_BORROW

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

See Also:
Constant Field Values

KEY_TEST_QUERY

public static final String KEY_TEST_QUERY
Key for test query.

See Also:
Constant Field Values

KEY_TEST_WHILE_IDLE

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

See Also:
Constant Field Values

KEY_TIME_BETWEEN_EVICTION_RUNS

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

See Also:
Constant Field Values

KEY_USERNAME

public static final String KEY_USERNAME
Key for user name.

See Also:
Constant Field Values

KEY_WHEN_EXHAUSTED_ACTION

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

See Also:
Constant Field Values

OPENCMS_DEFAULT_POOL_NAME

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

See Also:
Constant Field Values

OPENCMS_DEFAULT_POOL_URL

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

See Also:
Constant Field Values

OPENCMS_URL_PREFIX

public static final 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(CmsParameterConfiguration config,
                                                                                      String key)
                                                                               throws Exception
Creates a JDBC DriverManager based DBCP connection pool.

Parameters:
config - 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:
Exception - if the pool could not be initialized

getDbPoolName

public static String getDbPoolName(CmsParameterConfiguration configuration,
                                   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 List<String> getDbPoolUrls(CmsParameterConfiguration 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 String getDefaultDbPoolName()
Returns the name of the default database connection pool.

Returns:
the name of the default database connection pool