Example usage for org.apache.commons.dbcp AbandonedObjectPool setConfig

List of usage examples for org.apache.commons.dbcp AbandonedObjectPool setConfig

Introduction

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

Prototype

public synchronized void setConfig(GenericObjectPool.Config conf) 

Source Link

Document

Sets my configuration.

Usage

From source file:org.eclipse.osee.jdbc.internal.PooledDataSourceFetcher.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private ObjectPool<Connection> createConnectionPool() throws Exception {
    MetaData metadata = manager.getMetaData(dbInfo);

    JdbcConnectionFactory proxiedFactory = manager.getFactory(dbInfo.getDriver());
    ConnectionFactory connectionFactory = new ConnectionFactoryProxy(proxiedFactory, dbInfo,
            metadata.isTxIsolationLevelSupported());

    AbandonedObjectPool connectionPool = new AbandonedObjectPool(null,
            getAbandonedConnectionConfig(poolConfig));
    connectionPool.setConfig(getPoolConfig(poolConfig));

    GenericKeyedObjectPoolFactory statementPool = null;
    if (poolConfig.isPoolPreparedStatementsAllowed()) {
        statementPool = new GenericKeyedObjectPoolFactory(null, getStatementPoolConfig(poolConfig));
    }// w  ww . ja  v  a 2  s.c  o  m
    AbandonedConfig abandoned = new AbandonedConfig();
    abandoned.setLogAbandoned(true);
    abandoned.setLogWriter(new PrintWriter(System.out));

    String validationQuery = metadata.getValidationQuery();
    int validationQueryTimeoutSecs = poolConfig.getPoolValidationQueryTimeoutSecs();
    boolean defaultReadOnly = false;
    boolean defaultAutoCommit = true;
    new PoolableConnectionFactory(connectionFactory, connectionPool, statementPool, validationQuery,
            validationQueryTimeoutSecs, defaultReadOnly, defaultAutoCommit);
    return connectionPool;
}