List of usage examples for org.apache.commons.pool.impl GenericKeyedObjectPool GenericKeyedObjectPool
public GenericKeyedObjectPool()
GenericKeyedObjectPool
with no factory. From source file:TestKeyedObjectPool.java
public static void main(String args[]) throws Exception { GenericKeyedObjectPool pool = new GenericKeyedObjectPool(); pool.setFactory(new SkilledEmployeeFactory()); pool.addObject("Java"); pool.addObject("Java"); pool.addObject("VB"); pool.addObject("C++"); System.err.println("Number of Java employees in pool: " + pool.getNumIdle("Java") + " out of total employees: " + pool.getNumIdle());//from w ww . j a v a 2s . c om Employee employee = (Employee)pool.borrowObject("Java"); employee.doWork(); System.err.println("Employee: " + employee); pool.returnObject("Java", employee); System.err.println("Number of Java employees in pool: " + pool.getNumIdle("Java") + " out of total employees: " + pool.getNumIdle()); }
From source file:com.alibaba.otter.shared.communication.core.impl.connection.CommunicationConnectionPoolFactory.java
public void initial() { if (factory == null) { throw new IllegalArgumentException("factory is null!"); }/*from w w w . j a v a2s. c o m*/ // pool = new GenericKeyedObjectPool(); pool.setMaxActive(maxActive); pool.setMaxIdle(maxActive); pool.setMinIdle(0); pool.setMaxWait(60 * 1000); // 60s pool.setTestOnBorrow(false); pool.setTestOnReturn(false); pool.setTimeBetweenEvictionRunsMillis(10 * 1000); pool.setNumTestsPerEvictionRun(maxActive * 2); pool.setMinEvictableIdleTimeMillis(30 * 60 * 1000); pool.setTestWhileIdle(true); pool.setFactory(new CommunicationConnectionPoolableFactory(factory)); // ? }
From source file:edu.illinois.enforcemop.examples.apache.pool.TestGenericKeyedObjectPool.java
public void testSettersAndGetters() throws Exception { GenericKeyedObjectPool pool = new GenericKeyedObjectPool(); {/*from ww w. ja v a 2 s . c om*/ pool.setFactory(new SimpleFactory()); } { pool.setMaxActive(123); assertEquals(123, pool.getMaxActive()); } { pool.setMaxIdle(12); assertEquals(12, pool.getMaxIdle()); } { pool.setMaxWait(1234L); assertEquals(1234L, pool.getMaxWait()); } { pool.setMinEvictableIdleTimeMillis(12345L); assertEquals(12345L, pool.getMinEvictableIdleTimeMillis()); } { pool.setNumTestsPerEvictionRun(11); assertEquals(11, pool.getNumTestsPerEvictionRun()); } { pool.setTestOnBorrow(true); assertTrue(pool.getTestOnBorrow()); pool.setTestOnBorrow(false); assertTrue(!pool.getTestOnBorrow()); } { pool.setTestOnReturn(true); assertTrue(pool.getTestOnReturn()); pool.setTestOnReturn(false); assertTrue(!pool.getTestOnReturn()); } { pool.setTestWhileIdle(true); assertTrue(pool.getTestWhileIdle()); pool.setTestWhileIdle(false); assertTrue(!pool.getTestWhileIdle()); } { pool.setTimeBetweenEvictionRunsMillis(11235L); assertEquals(11235L, pool.getTimeBetweenEvictionRunsMillis()); } { pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); assertEquals(GenericObjectPool.WHEN_EXHAUSTED_BLOCK, pool.getWhenExhaustedAction()); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL); assertEquals(GenericObjectPool.WHEN_EXHAUSTED_FAIL, pool.getWhenExhaustedAction()); pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); assertEquals(GenericObjectPool.WHEN_EXHAUSTED_GROW, pool.getWhenExhaustedAction()); } }
From source file:edu.illinois.enforcemop.examples.apache.pool.TestGenericKeyedObjectPool.java
public void testConstructors() { // Make constructor arguments all different from defaults int maxActive = 1; int maxIdle = 2; long maxWait = 3; int minIdle = 4; int maxTotal = 5; long minEvictableIdleTimeMillis = 6; int numTestsPerEvictionRun = 7; boolean testOnBorrow = true; boolean testOnReturn = true; boolean testWhileIdle = true; long timeBetweenEvictionRunsMillis = 8; byte whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW; boolean lifo = false; GenericKeyedObjectPool pool = new GenericKeyedObjectPool(); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_ACTIVE, pool.getMaxActive()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_WAIT, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, pool.getMinEvictableIdleTimeMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, pool.getNumTestsPerEvictionRun()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW, pool.getTestOnBorrow()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN, pool.getTestOnReturn()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE, pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); GenericKeyedObjectPool.Config config = new GenericKeyedObjectPool.Config(); config.lifo = lifo;//from ww w. jav a 2s . c o m config.maxActive = maxActive; config.maxIdle = maxIdle; config.minIdle = minIdle; config.maxTotal = maxTotal; config.maxWait = maxWait; config.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; config.numTestsPerEvictionRun = numTestsPerEvictionRun; config.testOnBorrow = testOnBorrow; config.testOnReturn = testOnReturn; config.testWhileIdle = testWhileIdle; config.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; config.whenExhaustedAction = whenExhaustedAction; pool = new GenericKeyedObjectPool(null, config); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(minIdle, pool.getMinIdle()); assertEquals(maxTotal, pool.getMaxTotal()); assertEquals(minEvictableIdleTimeMillis, pool.getMinEvictableIdleTimeMillis()); assertEquals(numTestsPerEvictionRun, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(testWhileIdle, pool.getTestWhileIdle()); assertEquals(timeBetweenEvictionRunsMillis, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(lifo, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive); assertEquals(maxActive, pool.getMaxActive()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_WAIT, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, pool.getMinEvictableIdleTimeMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, pool.getNumTestsPerEvictionRun()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW, pool.getTestOnBorrow()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN, pool.getTestOnReturn()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE, pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait); assertEquals(maxActive, pool.getMaxActive()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, pool.getMinEvictableIdleTimeMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, pool.getNumTestsPerEvictionRun()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW, pool.getTestOnBorrow()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN, pool.getTestOnReturn()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE, pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, testOnBorrow, testOnReturn); assertEquals(maxActive, pool.getMaxActive()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, pool.getMinEvictableIdleTimeMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE, pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, maxIdle); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, pool.getMinEvictableIdleTimeMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, pool.getNumTestsPerEvictionRun()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW, pool.getTestOnBorrow()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN, pool.getTestOnReturn()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE, pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, maxIdle, testOnBorrow, testOnReturn); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, pool.getMinEvictableIdleTimeMillis()); assertEquals(GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE, pool.getTestWhileIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, maxIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, pool.getMaxTotal()); assertEquals(minEvictableIdleTimeMillis, pool.getMinEvictableIdleTimeMillis()); assertEquals(numTestsPerEvictionRun, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(testWhileIdle, pool.getTestWhileIdle()); assertEquals(timeBetweenEvictionRunsMillis, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, maxIdle, maxTotal, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(GenericKeyedObjectPool.DEFAULT_MIN_IDLE, pool.getMinIdle()); assertEquals(maxTotal, pool.getMaxTotal()); assertEquals(minEvictableIdleTimeMillis, pool.getMinEvictableIdleTimeMillis()); assertEquals(numTestsPerEvictionRun, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(testWhileIdle, pool.getTestWhileIdle()); assertEquals(timeBetweenEvictionRunsMillis, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, maxIdle, maxTotal, minIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(minIdle, pool.getMinIdle()); assertEquals(maxTotal, pool.getMaxTotal()); assertEquals(minEvictableIdleTimeMillis, pool.getMinEvictableIdleTimeMillis()); assertEquals(numTestsPerEvictionRun, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(testWhileIdle, pool.getTestWhileIdle()); assertEquals(timeBetweenEvictionRunsMillis, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo()); pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait, maxIdle, maxTotal, minIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle, lifo); assertEquals(maxActive, pool.getMaxActive()); assertEquals(maxIdle, pool.getMaxIdle()); assertEquals(maxWait, pool.getMaxWait()); assertEquals(minIdle, pool.getMinIdle()); assertEquals(maxTotal, pool.getMaxTotal()); assertEquals(minEvictableIdleTimeMillis, pool.getMinEvictableIdleTimeMillis()); assertEquals(numTestsPerEvictionRun, pool.getNumTestsPerEvictionRun()); assertEquals(testOnBorrow, pool.getTestOnBorrow()); assertEquals(testOnReturn, pool.getTestOnReturn()); assertEquals(testWhileIdle, pool.getTestWhileIdle()); assertEquals(timeBetweenEvictionRunsMillis, pool.getTimeBetweenEvictionRunsMillis()); assertEquals(whenExhaustedAction, pool.getWhenExhaustedAction()); assertEquals(lifo, pool.getLifo()); }
From source file:org.mule.transport.DefaultConfigurableKeyedObjectPool.java
public DefaultConfigurableKeyedObjectPool() { pool = new GenericKeyedObjectPool(); // NOTE: testOnBorrow MUST be FALSE. this is a bit of a design bug in // commons-pool since validate is used for both activation and passivation, // but has no way of knowing which way it is going. pool.setTestOnBorrow(false);//from ww w. ja v a 2 s . co m pool.setTestOnReturn(true); }
From source file:org.springframework.ldap.pool.factory.PoolingContextSource.java
/** * Creates a new pooling context source, setting up the DirContext object * factory and generic keyed object pool. *///from w w w . jav a2 s . com public PoolingContextSource() { this.dirContextPoolableObjectFactory = new DirContextPoolableObjectFactory(); this.keyedObjectPool = new GenericKeyedObjectPool(); this.keyedObjectPool.setFactory(this.dirContextPoolableObjectFactory); }
From source file:org.wso2.carbon.databridge.agent.client.ClientPool.java
public GenericKeyedObjectPool getClientPool(AbstractClientPoolFactory factory, int maxActive, int maxIdle, boolean testOnBorrow, long timeBetweenEvictionRunsMillis, long minEvictableIdleTimeMillis) { if (socketPool == null) { synchronized (this) { if (socketPool == null) { socketPool = new GenericKeyedObjectPool(); socketPool.setFactory(factory); socketPool.setMaxActive(maxActive); socketPool.setTestOnBorrow(testOnBorrow); socketPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); socketPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); socketPool.setMaxIdle(maxIdle); socketPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); }/* w w w . j a v a 2 s .c o m*/ } } return socketPool; }
From source file:org.wso2.carbon.databridge.agent.client.ClientPool.java
public GenericKeyedObjectPool getClientPool(AbstractSecureClientPoolFactory factory, int maxActive, int maxIdle, boolean testOnBorrow, long timeBetweenEvictionRunsMillis, long minEvictableIdleTimeMillis) { if (secureSocketPool == null) { synchronized (this) { if (secureSocketPool == null) { secureSocketPool = new GenericKeyedObjectPool(); secureSocketPool.setFactory(factory); secureSocketPool.setMaxActive(maxActive); secureSocketPool.setTestOnBorrow(testOnBorrow); secureSocketPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); secureSocketPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); secureSocketPool.setMaxIdle(maxIdle); secureSocketPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); }/* w w w . j a va 2 s. c o m*/ } } return secureSocketPool; }
From source file:org.wso2.carbon.stream.processor.core.ha.transport.EventSyncConnectionPoolManager.java
public synchronized static void initializeConnectionPool(EventSyncConnectionPoolFactory factory, int maxActive, int maxTotal, int maxIdle, long maxWait, long minEvictableIdleTimeMillis) { if (connectionPool == null) { connectionPool = new GenericKeyedObjectPool(); connectionPool.setFactory(factory); connectionPool.setMaxTotal(maxTotal); connectionPool.setMaxActive(maxActive); connectionPool.setTestOnBorrow(true); connectionPool.setTimeBetweenEvictionRunsMillis(12000); connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); connectionPool.setMaxIdle(maxIdle); connectionPool.setMaxWait(maxWait); connectionPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); }//from w w w .j a v a 2s. c o m }