result.setInPool(false);
    public PooledObject take() throws SQLException {                long startTime = System.currentTimeMillis();        if (LOG_DEBUG_INFO && getLogger() != null)            getLogger().debug(                "Thread "                    + Thread.currentThread().getName()                    + " wants to take connection.");        PooledObject result = null;                SQLException pendingExceptions = null;        try {            synchronized(takeMutex) {                if (stack.isEmpty()) {                        while (result == null) {                                                if (!keepBlocking(startTime)) {                            SQLException ex = new SQLException(                                "Could not obtain connection during " +                                 "blocking timeout (" + blockingTimeout + " ms)");                                                            if (pendingExceptions != null)                                ex.setNextException(ex);                                                        throw ex;                        };                            boolean connectionAdded = false;                            try {                            connectionAdded = addConnection(stack);                        } catch (SQLException sqlex) {                            if (getLogger() != null)                                getLogger().warn(                                    "Could not create connection."                                    + sqlex.getMessage());                                // could not add connection... bad luck                            // let's wait more                                                        if (pendingExceptions == null)                                pendingExceptions = sqlex;                            else                            if (pendingExceptions.getErrorCode() != sqlex.getErrorCode())                                pendingExceptions.setNextException(sqlex);                            }                            if (!connectionAdded) {                            String message =                                "Pool "                                    + queueName                                    + " is empty and will block here."                                    + " Thread "                                    + Thread.currentThread().getName();                                if (SHOW_STACK_ON_BLOCK) {                                if (getLogger() != null)                                    getLogger().warn(message, new Exception());                            } else {                                if (getLogger() != null)                                    getLogger().warn(message);                            }                                blocked = true;                        }                                                result = (PooledObject) stack.pop(                            getConfiguration().getRetryInterval());                                                    if (result == null && getLogger() != null)                            getLogger().warn("No connection in pool. Thread " +                                Thread.currentThread().getName());                        else                        if (result != null && !connectionAdded && getLogger() != null)                            getLogger().info("Obtained connection. Thread " +                                 Thread.currentThread().getName());                    }                    } else {                    result = (PooledObject)stack.pop();                }            }        } catch (InterruptedException iex) {            throw new SQLException(                "No free connection was available and "                    + "waiting thread was interrupted.");        }        size--;        workingConnections.add(result);        if (LOG_DEBUG_INFO && getLogger() != null) {            if (SHOW_STACK_ON_ALLOCATION)                getLogger().debug(                    "Thread "+ Thread.currentThread().getName() +                     " got connection.", new Exception());            else                getLogger().debug(                    "Thread "+ Thread.currentThread().getName() +                     " got connection.");        }        return result;    }