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


Java ConnectionEvent.getSource方法代碼示例

本文整理匯總了Java中javax.sql.ConnectionEvent.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Java ConnectionEvent.getSource方法的具體用法?Java ConnectionEvent.getSource怎麽用?Java ConnectionEvent.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.sql.ConnectionEvent的用法示例。


在下文中一共展示了ConnectionEvent.getSource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的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: connectionClosed

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
public synchronized void connectionClosed(ConnectionEvent event) {

        PooledConnection connection = (PooledConnection) event.getSource();

        this.connectionsInUse.remove(connection);
        this.sessionConnectionWrappers.remove(connection);

        if (!this.isPoolClosed) {
            enqueue(connection);
            logInfo("Connection returned to pool.");
        } else {
            closePhysically(connection, "closing returned connection.");
            logInfo(
                "Connection returned to pool was closed because pool is closed.");
            this.notifyAll();    //notifies evt. threads waiting for connection or for the pool to close.
        }
    }
 
開發者ID:s-store,項目名稱:s-store,代碼行數:18,代碼來源:ManagedPoolDataSource.java

示例3: connectionClosed

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * Implementation of call back function from ConnectionEventListener interface. This callback will
 * be invoked on connection close event.
 * 
 * @param event Connection event object
 */
public void connectionClosed(ConnectionEvent event) {
  if (isActive) {
    try {
      XAConnection conn = (XAConnection) event.getSource();
      XAResource xar = (XAResource) xaResourcesMap.get(conn);
      xaResourcesMap.remove(conn);
      Transaction txn = transManager.getTransaction();
      if (txn != null && xar != null)
        txn.delistResource(xar, XAResource.TMSUCCESS);
      provider.returnConnection(conn);
    } catch (Exception e) {
      String exception =
          "GemFireTransactionDataSource::connectionClosed: Exception occured due to " + e;
      if (logger.isDebugEnabled()) {
        logger.debug(exception, e);
      }
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:26,代碼來源:GemFireTransactionDataSource.java

示例4: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * Implementation of call back function from ConnectionEventListener interface. This callback will
 * be invoked on connection error event.
 * 
 * @param event
 */
public void connectionErrorOccurred(ConnectionEvent event) {
  if (isActive) {
    try {
      PooledConnection conn = (PooledConnection) event.getSource();
      provider.returnAndExpireConnection(conn);
    } catch (Exception ex) {
      String exception =
          "GemFireConnPooledDataSource::connectionErrorOccured:error in returning and expiring connection due to "
              + ex;
      if (logger.isDebugEnabled()) {
        logger.debug(exception, ex);
      }
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:GemFireConnPooledDataSource.java

示例5: connectionClosed

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
@Override
public synchronized void connectionClosed(ConnectionEvent event)
{
	PooledCassandraConnection connection = (PooledCassandraConnection) event.getSource();
	usedConnections.remove(connection);
	int freeConnectionsCount = freeConnections.size();
	if (freeConnectionsCount < MIN_POOL_SIZE)
	{
		freeConnections.add(connection);
	}
	else
	{
		try
		{
			connection.close();
		}
		catch (SQLException e)
		{
			logger.error(e.getMessage());
		}
	}
}
 
開發者ID:adejanovski,項目名稱:cassandra-jdbc-wrapper,代碼行數:23,代碼來源:PooledCassandraDataSource.java

示例6: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
@Override
public synchronized void connectionErrorOccurred(ConnectionEvent event)
{
	PooledCassandraConnection connection = (PooledCassandraConnection) event.getSource();
	try
	{
		if (!connection.getConnection().isValid(CONNECTION_IS_VALID_TIMEOUT)) {
			connection.getConnection().close();
		}
	}
	catch (SQLException e)
	{
		logger.error(e.getMessage());
	}
	usedConnections.remove(connection);
}
 
開發者ID:adejanovski,項目名稱:cassandra-jdbc-wrapper,代碼行數:17,代碼來源:PooledCassandraDataSource.java

示例7: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * If a fatal error occurs, close the underlying physical connection so as
 * not to be returned in the future
 */
public void connectionErrorOccurred(ConnectionEvent event) {
    PooledConnection pc = (PooledConnection)event.getSource();
    if (null != event.getSQLException()) {
        System.err
            .println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR (" +
                     event.getSQLException() + ")");
    }
    pc.removeConnectionEventListener(this);

    PooledConnectionAndInfo info = (PooledConnectionAndInfo) pcMap.get(pc);
    if (info == null) {
        throw new IllegalStateException(NO_KEY_MESSAGE);
    }
    try {
        _pool.invalidateObject(info.getUserPassKey(), info);
    } catch (Exception e) {
        System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info);
        e.printStackTrace();
    }
}
 
開發者ID:WhiteBearSolutions,項目名稱:WBSAirback,代碼行數:25,代碼來源:KeyedCPDSConnectionFactory.java

示例8: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * If a fatal error occurs, close the underlying physical connection so as
 * not to be returned in the future
 */
public void connectionErrorOccurred(ConnectionEvent event) {
    PooledConnection pc = (PooledConnection)event.getSource();
    if (null != event.getSQLException()) {
        System.err.println(
                "CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR ("
                + event.getSQLException() + ")");
    }
    pc.removeConnectionEventListener(this);

    Object info = pcMap.get(pc);
    if (info == null) {
        throw new IllegalStateException(NO_KEY_MESSAGE);
    }
    try {
        _pool.invalidateObject(info);
    } catch (Exception e) {
        System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info);
        e.printStackTrace();
    }
}
 
開發者ID:WhiteBearSolutions,項目名稱:WBSAirback,代碼行數:25,代碼來源:CPDSConnectionFactory.java

示例9: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * If a fatal error occurs, close the underlying physical connection so as
 * not to be returned in the future
 */
@Override
public void connectionErrorOccurred(final ConnectionEvent event) {
    final PooledConnection pc = (PooledConnection)event.getSource();
    if (null != event.getSQLException()) {
        System.err
            .println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR (" +
                     event.getSQLException() + ")");
    }
    pc.removeConnectionEventListener(this);

    final PooledConnectionAndInfo info = pcMap.get(pc);
    if (info == null) {
        throw new IllegalStateException(NO_KEY_MESSAGE);
    }
    try {
        _pool.invalidateObject(info.getUserPassKey(), info);
    } catch (final Exception e) {
        System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info);
        e.printStackTrace();
    }
}
 
開發者ID:apache,項目名稱:commons-dbcp,代碼行數:26,代碼來源:KeyedCPDSConnectionFactory.java

示例10: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * If a fatal error occurs, close the underlying physical connection so as
 * not to be returned in the future
 */
@Override
public void connectionErrorOccurred(final ConnectionEvent event) {
    final PooledConnection pc = (PooledConnection)event.getSource();
    if (null != event.getSQLException()) {
        System.err.println(
                "CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR ("
                + event.getSQLException() + ")");
    }
    pc.removeConnectionEventListener(this);

    final PooledConnectionAndInfo pci = pcMap.get(pc);
    if (pci == null) {
        throw new IllegalStateException(NO_KEY_MESSAGE);
    }
    try {
        _pool.invalidateObject(pci);
    } catch (final Exception e) {
        System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + pci);
        e.printStackTrace();
    }
}
 
開發者ID:apache,項目名稱:commons-dbcp,代碼行數:26,代碼來源:CPDSConnectionFactory.java

示例11: connectionClosed

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
public void connectionClosed(ConnectionEvent event) {
    PooledConnection connection = (PooledConnection) event.getSource();

    for (int i = 0; i < connections.length; i++) {
        if (connections[i] == connection) {
            states.set(i, RefState.available);

            break;
        }
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:12,代碼來源:JDBCPool.java

示例12: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
public void connectionErrorOccurred(ConnectionEvent event) {
    PooledConnection connection = (PooledConnection) event.getSource();

    for (int i = 0; i < connections.length; i++) {
        if (connections[i] == connection) {
            states.set(i, RefState.allocated);
            connections[i] = null;
            states.set(i, RefState.empty);
            break;
        }
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:13,代碼來源:JDBCPool.java

示例13: connectionErrorOccurred

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * Implementation of call back function from ConnectionEventListener interface. This callback will
 * be invoked on connection error event.
 * 
 * @param event Connection event object
 */
public void connectionErrorOccurred(ConnectionEvent event) {
  if (isActive) {
    try {
      PooledConnection conn = (PooledConnection) event.getSource();
      provider.returnAndExpireConnection(conn);
    } catch (Exception ex) {
      String exception =
          "GemFireTransactionDataSource::connectionErrorOccured: Exception occured due to " + ex;
      if (logger.isDebugEnabled()) {
        logger.debug(exception, ex);
      }
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:21,代碼來源:GemFireTransactionDataSource.java

示例14: connectionClosed

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * Implementation of call back function from ConnectionEventListener interface. This callback will
 * be invoked on connection close event.
 * 
 * @param event
 */
public void connectionClosed(ConnectionEvent event) {
  if (isActive) {
    try {
      PooledConnection conn = (PooledConnection) event.getSource();
      provider.returnConnection(conn);
    } catch (Exception ex) {
      String exception = "GemFireConnPooledDataSource::connectionclosed:Exception =" + ex;
      if (logger.isDebugEnabled()) {
        logger.debug(exception, ex);
      }
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:20,代碼來源:GemFireConnPooledDataSource.java

示例15: connectionClosed

import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
 * INTERNAL
 */
@Override
public void connectionClosed(ConnectionEvent event) {
    PooledConnection pc = (PooledConnection) event.getSource();
    pc.removeConnectionEventListener(this);
    recycleConnection(pc);
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:10,代碼來源:JdbcConnectionPool.java


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