protected PooledConnectionAndInfo getPooledConnectionAndInfo(String username, String password) throws SQLException { synchronized (this) { if (pool == null) { try { registerPool(username, password); } catch (NamingException e) { throw new SQLNestedException("RegisterPool failed", e); } } } PooledConnectionAndInfo info = null; UserPassKey key = new UserPassKey(username, password); try { info = (PooledConnectionAndInfo) pool.borrowObject(key); } catch (Exception e) { throw new SQLNestedException("Could not retrieve connection info from pool", e); } return info; }
/** Close pool being maintained by this datasource. */ public void close() throws Exception { if (pool != null) { pool.close(); } InstanceKeyObjectFactory.removeInstance(instanceKey); }
/** Get the number of idle connections in the pool. */ public int getNumIdle() { return (pool == null) ? 0 : pool.getNumIdle(); }
/** Get the number of active connections in the pool. */ public int getNumActive() { return (pool == null) ? 0 : pool.getNumActive(); }