List of usage examples for org.apache.commons.dbcp AbandonedObjectPool setMaxWait
public synchronized void setMaxWait(long maxWait)
From source file:com.haulmont.yarg.loaders.factory.DefaultLoaderFactory.java
public static DataSource setupDataSource(String driver, String connectURI, String username, String password, Integer maxActive, Integer maxIdle, Integer maxWait) { try {/*from w w w . ja v a2 s. co m*/ Class.forName(driver); final AbandonedConfig config = new AbandonedConfig(); config.setLogAbandoned(true); AbandonedObjectPool connectionPool = new AbandonedObjectPool(null, config); connectionPool.setMaxIdle(maxIdle); connectionPool.setMaxActive(maxActive); if (maxWait != null) { connectionPool.setMaxWait(maxWait); } ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI, username, password); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true); connectionPool.setFactory(poolableConnectionFactory); PoolingDataSource dataSource = new PoolingDataSource(connectionPool); return dataSource; } catch (ClassNotFoundException e) { throw new InitializationException("An error occurred during creation of new datasource object", e); } }
From source file:com.haulmont.yarg.console.PropertiesSqlLoaderFactory.java
protected DataSource setupDataSource(String driver, String connectURI, String username, String password, Integer maxActive, Integer maxIdle, Integer maxWait) { try {/*from w ww . j a v a2 s . c o m*/ Class.forName(driver); final AbandonedConfig config = new AbandonedConfig(); config.setLogAbandoned(true); AbandonedObjectPool connectionPool = new AbandonedObjectPool(null, config); connectionPool.setMaxIdle(maxIdle); connectionPool.setMaxActive(maxActive); if (maxWait != null) { connectionPool.setMaxWait(maxWait); } ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI, username, password); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true); connectionPool.setFactory(poolableConnectionFactory); return new PoolingDataSource(connectionPool); } catch (ClassNotFoundException e) { throw new InitializationException("An error occurred during creation of new datasource object", e); } }