/** * {@inheritDoc} * * Look into the pool for an unused DbProvider. If no one find, create one. */ @Override public DbConnection getConnection() throws Exception { log().t(getName(),"getConnection"); boolean foundClosed = false; try { synchronized (pool) { for (InternalDbConnection con : pool) { if (con.isClosed() || con.checkTimedOut()) { foundClosed = true; } else if (!con.isUsed()) { con.setUsed(true); return new DbConnectionProxy(this, con); } } return createConnection(); } } finally { if (foundClosed) cleanup(false); } }