Example usage for org.apache.commons.dbcp PoolingDriver PoolingDriver

List of usage examples for org.apache.commons.dbcp PoolingDriver PoolingDriver

Introduction

In this page you can find the example usage for org.apache.commons.dbcp PoolingDriver PoolingDriver.

Prototype

public PoolingDriver() 

Source Link

Usage

From source file:org.s23m.cell.repository.RelationalDatabaseRepository.java

private static void initializeConnectionPool() {
    final Properties props = new Properties();
    props.setProperty("user", ConfigValues.getValue("Repository.REPOSITORY_ACCOUNT"));
    props.setProperty("password", ConfigValues.getValue("Repository.REPOSITORY_PW"));
    props.setProperty("rewriteBatchedStatements", "true");
    final ConnectionFactory cf = new DriverManagerConnectionFactory(
            ConfigValues.getValue("Repository.REPOSITORY_CONNECTION_STRING"), props);
    final KeyedObjectPoolFactory keyedObjecPoolFacto = new GenericKeyedObjectPoolFactory(null,
            MAX_ACTIVE_CONNECTION);
    new PoolableConnectionFactory(cf, RepositoryHolder.CONNECTION_POOL, keyedObjecPoolFacto, null, false, true);
    for (int i = 0; i < INITIAL_CONNECTION_POOL_SIZE; i++) {
        try {//ww w.ja va2 s.com
            RepositoryHolder.CONNECTION_POOL.addObject();
        } catch (final Exception e) {
        }
    }
    new PoolingDriver().registerPool(REPOSITORY_CONNECTION_POOL_ID, RepositoryHolder.CONNECTION_POOL);
    RepositoryHolder.setConnectionPoolInitialized(true);
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Sets the database connection pool./*w  w  w  .ja v a  2 s.  co  m*/
 * 
 * @param connectURI
 *          The url specifying the database to which it connects
 * @param pUserId
 *          The user id field
 * @param pPassword
 *          The password field
 */
private void setupDBPool(String connectURI, String pUserId, String pPassword) {
    removeDBPool();

    try {
        final GenericObjectPool connectionPool = new GenericObjectPool(null);

        configurePool(connectionPool, connectURI, pUserId, pPassword);

        final PoolingDriver driver = new PoolingDriver();
        driver.registerPool(DBPOOL_NAME, connectionPool);
        LOGGER.info("DB Connection Pool setup [" + DBPOOL_NAME + "]");
    } catch (Throwable any) {
        LOGGER.error("Unable to setup database connection pool", any);
        messageOut(Resources.getString("errFailSetupDBPool", any.getMessage()), STYLE_RED);
    }
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Gets the driver for the database pool
 * //from   w  w w.  ja  v  a 2  s.c  om
 * @return ObjectPool Returns the driver object for the specific
 *         pool name
 */
private ObjectPool getDBPool() {
    try {
        return new PoolingDriver().getConnectionPool(DBPOOL_NAME);
    } catch (SQLException excSQL) {
        LOGGER.error("Unable to load DB Pool", excSQL);
        return null;
    }
}