protected Connection waitAndGet(int wait) throws SQLException {
        Connection conn = null;
        try {
            conn = this.availableConnections.poll(wait, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            throw new SQLException("Connection pool wait interrupted before " + wait + " milliseconds");
        }
        boolean decrementIfNull = false;
        if (conn != null && conn.isClosed()) {
            decrementIfNull = true;
            conn = this.reconnect(conn);
            if (log.isDebugEnabled()) {
                log.info("Reconnected: " + conn);
            }
        }
        if (!this.offerToBusy(conn)) {
            conn = null;
        } else {
            if (log.isDebugEnabled()) {
                log.debug(this.capacityInfo("Connection[" + conn + "] added to busy.", "\n"));
            }
        }
        if (decrementIfNull && conn == null) {
            this.size.decrementAndGet();
        }
        return conn;
    }