本文整理匯總了Java中javax.sql.PooledConnection.removeConnectionEventListener方法的典型用法代碼示例。如果您正苦於以下問題:Java PooledConnection.removeConnectionEventListener方法的具體用法?Java PooledConnection.removeConnectionEventListener怎麽用?Java PooledConnection.removeConnectionEventListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sql.PooledConnection
的用法示例。
在下文中一共展示了PooledConnection.removeConnectionEventListener方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: connectionErrorOccurred
import javax.sql.PooledConnection; //導入方法依賴的package包/類
/**
*
* A fatal error has occurred and the connection cannot be used anymore.
* A close event from such a connection should be ignored. The connection should not be reused.
* A new connection will be created to replace the invalid connection, when the next client
* calls getConnection().
*/
public synchronized void connectionErrorOccurred(ConnectionEvent event) {
PooledConnection connection = (PooledConnection) event.getSource();
connection.removeConnectionEventListener(this);
this.connectionsInUse.remove(connection);
this.sessionConnectionWrappers.remove(connection);
logInfo(
"Fatal exception occurred on pooled connection. Connection is removed from pool: ");
logInfo(event.getSQLException());
closePhysically(connection, "closing invalid, removed connection.");
//notify threads waiting for connections or for the pool to close.
//one waiting thread can now create a new connection since the pool has space for a new connection.
//if a thread waits for the pool to close this could be the last unclosed connection in the pool.
this.notifyAll();
}
示例2: disposeConnection
import javax.sql.PooledConnection; //導入方法依賴的package包/類
private synchronized void disposeConnection(PooledConnection pconn) {
pconn.removeConnectionEventListener(poolConnectionEventListener);
if (!recycledConnections.remove(pconn) && pconn != connectionInTransition) {
// If the PooledConnection is not in the recycledConnections list
// and is not currently within a PooledConnection.getConnection() call,
// we assume that the connection was active.
if (activeConnections <= 0) {
throw new AssertionError();
}
activeConnections--;
semaphore.release();
}
closeConnectionAndIgnoreException(pconn);
assertInnerState();
}