/** * Releases the given connection back to the pool. This method is not intended to be called by * applications (hence set to protected). Call connection.close() instead which will return * the connection back to the pool. * * @param connection to release * @throws SQLException */ protected void releaseConnection(Connection connection) throws SQLException { ConnectionHandle handle = (ConnectionHandle)connection; // hook calls if (handle.getConnectionHook() != null){ handle.getConnectionHook().onCheckIn(handle); } // release immediately or place it in a queue so that another thread will eventually close it. If we're shutting down, // close off the connection right away because the helper threads have gone away. if (!this.poolShuttingDown){ internalReleaseConnection(handle); } }
/** * Releases the given connection back to the pool. This method is not intended to be called by * applications (hence set to protected). Call connection.close() instead which will return * the connection back to the pool. * * @param connection to release * @throws SQLException */ protected void releaseConnection(Connection connection) throws SQLException { ConnectionHandle handle = (ConnectionHandle) connection; // hook calls if (handle.getConnectionHook() != null) { handle.getConnectionHook().onCheckIn(handle); } // release immediately or place it in a queue so that another thread will eventually close it. If we're shutting down, // close off the connection right away because the helper threads have gone away. if (!this.poolShuttingDown) { internalReleaseConnection(handle); } }
/** After obtaining a connection, perform additional tasks. * @param handle * @param statsObtainTime */ protected void postConnection(ConnectionHandle handle, long statsObtainTime){ handle.renewConnection(); // mark it as being logically "open" // Give an application a chance to do something with it. if (handle.getConnectionHook() != null){ handle.getConnectionHook().onCheckOut(handle); } if (this.pool.closeConnectionWatch){ // a debugging tool this.pool.watchConnection(handle); } if (this.pool.statisticsEnabled){ this.pool.statistics.addCumulativeConnectionWaitTime(System.nanoTime()-statsObtainTime); } }
/** Update counters and call hooks. * @param handle connection handle. */ protected void postDestroyConnection(ConnectionHandle handle){ ConnectionPartition partition = handle.getOriginatingPartition(); if (this.finalizableRefQueue != null && handle.getInternalConnection() != null){ //safety this.finalizableRefs.remove(handle.getInternalConnection()); // assert o != null : "Did not manage to remove connection from finalizable ref queue"; } partition.updateCreatedConnections(-1); partition.setUnableToCreateMoreTransactions(false); // we can create new ones now, this is an optimization // "Destroying" for us means: don't put it back in the pool. if (handle.getConnectionHook() != null){ handle.getConnectionHook().onDestroy(handle); } }
/** * Update counters and call hooks. * * @param handle connection handle. */ protected void postDestroyConnection(ConnectionHandle handle) { ConnectionPartition partition = handle.getOriginatingPartition(); if (this.finalizableRefQueue != null && handle.getInternalConnection() != null) { //safety check this.finalizableRefs.remove(handle.getInternalConnection()); // o != null : "Did not manage to remove connection from finalizable ref queue"; } partition.updateCreatedConnections(-1); // we can create new ones now, this is an optimization partition.setUnableToCreateMoreTransactions(false); // "Destroying" for us means: don't put it back in the pool. if (handle.getConnectionHook() != null) { handle.getConnectionHook().onDestroy(handle); } }
boolean alreadyDestroyed = false; ConnectionState connectionState = this.getConnectionHook() != null ? this.getConnectionHook().onMarkPossiblyBroken(this, state, e) : ConnectionState.NOP; if (state == null){ // safety; state = "08999"; if (this.possiblyBroken && (this.getConnectionHook() != null)){ this.possiblyBroken = this.getConnectionHook().onConnectionException(this, state, e);