本文整理汇总了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();
}