It is a common function of a connection pool to support "purging" the pool of all current connections and getting all fresh connections. Oracle UCP and Websphere pools are two such examples. It would be great if this pool supported such an operation as well. It would be useful if the operation were exposed through JMX too.
Fixed in trunk in r1340160 Fixed in 7.0.x in r1340164
Nice! Thanks Filip! For laughs here is the workaround implementation I created yesterday. :) public void purge() throws Exception { long oldMaxAge = dataSource.getMaxAge(); int oldMaxIdle = dataSource.getMaxIdle(); int oldMaxActive = dataSource.getMaxActive(); int oldMinEvictTime = dataSource.getMinEvictableIdleTimeMillis(); PooledConnection connection = dataSource.getPooledConnection(); IllegalStateException error = null; try { dataSource.setMaxActive(1); dataSource.setMaxIdle(1); dataSource.setMaxAge(1); dataSource.setMinEvictableIdleTimeMillis(1); int sec = 0; Thread.sleep(1001); while(dataSource.getActive() > 1 && sec < 29) { Thread.sleep(1000); sec++; } dataSource.checkIdle(); if(dataSource.getActive() > 1) { error = new IllegalStateException("Closed all but "+(dataSource.getActive()-1)+" connection(s) after 30 sec. Try again."); } connection.close(); } finally { dataSource.setMaxAge(oldMaxAge); dataSource.setMaxActive(oldMaxActive); dataSource.setMaxIdle(oldMaxIdle); dataSource.setMinEvictableIdleTimeMillis(oldMinEvictTime); if(error != null) { throw error; } } }