當前位置: 首頁>>代碼示例>>Java>>正文


Java PooledConnection.removeConnectionEventListener方法代碼示例

本文整理匯總了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();
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:25,代碼來源:ManagedPoolDataSource.java

示例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();
}
 
開發者ID:stechy1,項目名稱:drd,代碼行數:16,代碼來源:MiniConnectionPoolManager.java


注:本文中的javax.sql.PooledConnection.removeConnectionEventListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。