/** Adds a connection to the idle pool. */
  void toIdle(ManagedPoolItem item) {
    try {
      if (_maxConnections < _connectionPool.size() || item.isConnectionError()) {
        return;
      }

      ManagedConnection mConn = item.getManagedConnection();

      if (mConn == null) {
        return;
      }

      mConn.cleanup();

      long now = CurrentTime.getCurrentTime();

      if (_idlePool.size() == 0) _idlePoolExpire = now + _idleTimeout;

      if (_idlePoolExpire < now) {
        // shrink the idle pool when non-empty for idleTimeout
        _idlePoolExpire = now + _idleTimeout;
      } else if (_idlePool.add(mConn)) {
        item = null;
        return;
      }
    } catch (Exception e) {
      log.log(Level.FINE, e.toString(), e);
    } finally {
      notifyConnectionAvailable();

      if (item != null) item.destroy();
    }
  }
 /** Returns the active connections. */
 @Override
 public int getConnectionActiveCount() {
   return _connectionPool.size() - _idlePool.size();
 }
 /** True if idlePool has an available connection. */
 private boolean isIdleAvailable() {
   return _idlePool.size() > 0;
 }
 /** Returns the idle connections. */
 @Override
 public int getConnectionIdleCount() {
   return _idlePool.size();
 }