List of usage examples for org.apache.commons.dbcp2 SwallowedExceptionLogger SwallowedExceptionLogger
public SwallowedExceptionLogger(Log log, boolean logExpiredConnections)
From source file:JDBCPool.dbcp.demo.sourcecode.BasicDataSource.java
/** * Creates a connection pool for this datasource. This method only exists * so subclasses can replace the implementation class. * * This implementation configures all pool properties other than * timeBetweenEvictionRunsMillis. Setting that property is deferred to * {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis * to a positive value causes {@link GenericObjectPool}'s eviction timer * to be started.//ww w. j a v a 2 s . c o m */ protected void createConnectionPool(PoolableConnectionFactory factory) { // Create an object pool to contain our active connections GenericObjectPoolConfig config = new GenericObjectPoolConfig(); updateJmxName(config); config.setJmxEnabled(registeredJmxName != null); // Disable JMX on the underlying pool if the DS is not registered. GenericObjectPool<PoolableConnection> gop; if (abandonedConfig != null && (abandonedConfig.getRemoveAbandonedOnBorrow() || abandonedConfig.getRemoveAbandonedOnMaintenance())) { gop = new GenericObjectPool<>(factory, config, abandonedConfig); } else { gop = new GenericObjectPool<>(factory, config); } gop.setMaxTotal(maxTotal); gop.setMaxIdle(maxIdle); gop.setMinIdle(minIdle); gop.setMaxWaitMillis(maxWaitMillis); gop.setTestOnCreate(testOnCreate); gop.setTestOnBorrow(testOnBorrow); gop.setTestOnReturn(testOnReturn); gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun); gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); gop.setTestWhileIdle(testWhileIdle); gop.setLifo(lifo); gop.setSwallowedExceptionListener(new SwallowedExceptionLogger(log, logExpiredConnections)); gop.setEvictionPolicyClassName(evictionPolicyClassName); factory.setPool(gop); connectionPool = gop; }