Java 类javax.sql.ConnectionEvent 实例源码

项目:spanner-jdbc    文件:CloudSpannerPooledConnection.java   
/**
 * Used to fire a connection closed event to all listeners.
 */
void fireConnectionClosed()
{
    ConnectionEvent evt = null;
    // Copy the listener list so the listener can remove itself during this
    // method call
    ConnectionEventListener[] local = listeners.toArray(new ConnectionEventListener[listeners.size()]);
    for (ConnectionEventListener listener : local)
    {
        if (evt == null)
        {
            evt = createConnectionEvent(null);
        }
        listener.connectionClosed(evt);
    }
}
项目:spanner-jdbc    文件:CloudSpannerPooledConnection.java   
/**
 * Used to fire a connection error event to all listeners.
 */
void fireConnectionFatalError(SQLException e)
{
    ConnectionEvent evt = null;
    // Copy the listener list so the listener can remove itself during this
    // method call
    ConnectionEventListener[] local = listeners.toArray(new ConnectionEventListener[listeners.size()]);
    for (ConnectionEventListener listener : local)
    {
        if (evt == null)
        {
            evt = createConnectionEvent(e);
        }
        listener.connectionErrorOccurred(evt);
    }
}
项目:sstore-soft    文件:ManagedPoolDataSource.java   
/**
 *
 * 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();
}
项目:the-vigilantes    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:s-store    文件:ManagedPoolDataSource.java   
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.
        }
    }
项目:s-store    文件:ManagedPoolDataSource.java   
/**
 *
 * 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();
}
项目:OpenVertretung    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:lams    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:ProyectoPacientes    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:monarch    文件:GemFireTransactionDataSource.java   
/**
 * 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);
      }
    }
  }
}
项目:monarch    文件:GemFireConnPooledDataSource.java   
/**
 * 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);
      }
    }
  }
}
项目:BibliotecaPS    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:gemfirexd-oss    文件:ClientPooledConnection.java   
/**
 * Fire all the {@code ConnectionEventListener}s registered. Callers must
 * synchronize on {@code this} to prevent others from modifying the list of
 * listeners.
 *
 * @param exception the exception that caused the event, or {@code null} if
 * it is a close event
 */
private void fireConnectionEventListeners(SqlException exception) {
    if (!listeners_.isEmpty()) {
        final ConnectionEvent event = (exception == null) ?
            new ConnectionEvent(this) :
            new ConnectionEvent(this, exception.getSQLException(
                physicalConnection_ != null ? physicalConnection_
                    .agent_ : null /* GemStoneAddition */));
        eventIterators++;
        try {
            for (Iterator it = listeners_.iterator(); it.hasNext(); ) {
                final ConnectionEventListener listener =
                    (ConnectionEventListener) it.next();
                if (exception == null) {
                    listener.connectionClosed(event);
                } else {
                    listener.connectionErrorOccurred(event);
                }
            }
        } finally {
            eventIterators--;
        }
    }
}
项目:gemfirexd-oss    文件:EmbedPooledConnection.java   
/**
 * Fire all the {@code ConnectionEventListener}s registered. Callers must
 * synchronize on {@code this} to prevent others from modifying the list of
 * listeners.
 *
 * @param exception the exception that caused the event, or {@code null} if
 * it is a close event
 */
private void fireConnectionEventListeners(SQLException exception) {
    if (eventListener != null && !eventListener.isEmpty()) {
        ConnectionEvent event = new ConnectionEvent(this, exception);
        eventIterators++;
        try {
            for (Iterator it = eventListener.iterator(); it.hasNext();) {
                ConnectionEventListener l =
                        (ConnectionEventListener) it.next();
                if (exception == null) {
                    l.connectionClosed(event);
                } else {
                    l.connectionErrorOccurred(event);
                }
            }
        } finally {
            eventIterators--;
        }
    }
}
项目:Geometry-wars    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:TPKB    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:VoltDB    文件:ManagedPoolDataSource.java   
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.
        }
    }
项目:VoltDB    文件:ManagedPoolDataSource.java   
/**
 *
 * 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();
}
项目:gemfirexd-oss    文件:ClientPooledConnection.java   
/**
 * Fire all the {@code ConnectionEventListener}s registered. Callers must
 * synchronize on {@code this} to prevent others from modifying the list of
 * listeners.
 *
 * @param exception the exception that caused the event, or {@code null} if
 * it is a close event
 */
private void fireConnectionEventListeners(SqlException exception) {
    if (!listeners_.isEmpty()) {
        final ConnectionEvent event = (exception == null) ?
            new ConnectionEvent(this) :
            new ConnectionEvent(this, exception.getSQLException(
                physicalConnection_ != null ? physicalConnection_
                    .agent_ : null /* GemStoneAddition */));
        eventIterators++;
        try {
            for (Iterator it = listeners_.iterator(); it.hasNext(); ) {
                final ConnectionEventListener listener =
                    (ConnectionEventListener) it.next();
                if (exception == null) {
                    listener.connectionClosed(event);
                } else {
                    listener.connectionErrorOccurred(event);
                }
            }
        } finally {
            eventIterators--;
        }
    }
}
项目:gemfirexd-oss    文件:EmbedPooledConnection.java   
/**
 * Fire all the {@code ConnectionEventListener}s registered. Callers must
 * synchronize on {@code this} to prevent others from modifying the list of
 * listeners.
 *
 * @param exception the exception that caused the event, or {@code null} if
 * it is a close event
 */
private void fireConnectionEventListeners(SQLException exception) {
    if (eventListener != null && !eventListener.isEmpty()) {
        ConnectionEvent event = new ConnectionEvent(this, exception);
        eventIterators++;
        try {
            for (Iterator it = eventListener.iterator(); it.hasNext();) {
                ConnectionEventListener l =
                        (ConnectionEventListener) it.next();
                if (exception == null) {
                    l.connectionClosed(event);
                } else {
                    l.connectionErrorOccurred(event);
                }
            }
        } finally {
            eventIterators--;
        }
    }
}
项目:cloudera-cli-scripts    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:fil_project_mgmt_app_v2    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType,
        SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this,
            sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener
                    .connectionErrorOccurred(connectionevent);
        }
    }
}
项目:teiid    文件:XAConnectionImpl.java   
/**
 * Notify listeners, if there is any, about the connection status.
 * If e is null, the connection is properly closed.
 * @param e
 */
protected synchronized void notifyListener(SQLException e){
    if(listeners != null && !listeners.isEmpty()){
        Iterator<ConnectionEventListener> iter = listeners.iterator();
        while(iter.hasNext()){
            ConnectionEventListener listener = iter.next();
            if(e == null){
                //no exception
                listener.connectionClosed(new ConnectionEvent(this));
            }else{
                //exception occurred
                listener.connectionErrorOccurred(new ConnectionEvent(this, e)); 
            }
        }
    }   
}
项目:cassandra-jdbc-wrapper    文件:PooledCassandraDataSource.java   
@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());
        }
    }
}
项目:cassandra-jdbc-wrapper    文件:PooledCassandraDataSource.java   
@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);
}
项目:In-the-Box-Fork    文件:ConnectionEventTest.java   
/**
 * @tests {@link javax.sql.ConnectionEvent#ConnectionEvent(PooledConnection)}
 *
 */
@TestTargetNew(
    level = TestLevel.SUFFICIENT,
    notes = "functional test missing but not feasible: no implementation available.",
    method = "ConnectionEvent",
    args = {javax.sql.PooledConnection.class}
)
public void testConstructorConnection() {
    try {
        new ConnectionEvent(null);
        fail("illegal argument exception expected");
    } catch (IllegalArgumentException e) {
    }

    Impl_PooledConnection ipc = new Impl_PooledConnection();
    ConnectionEvent ce = new ConnectionEvent(ipc);
    assertSame(ipc, ce.getSource());
    assertNull(ce.getSQLException());

    //cross test
    ConnectionEvent ce2 = new ConnectionEvent(ipc,null);
    assertSame(ce2.getSource(),ce.getSource());
}
项目:In-the-Box-Fork    文件:ConnectionEventTest.java   
/**
 * @tests {@link javax.sql.ConnectionEvent#getSQLException()}
 */
@TestTargetNew(
    level = TestLevel.SUFFICIENT,
    notes = "functional test missing but not feasible: no implementation available.",
    method = "getSQLException",
    args = {}
)
public void testGetSQLException() {

    Impl_PooledConnection ipc = new Impl_PooledConnection();
    ConnectionEvent ce = new ConnectionEvent(ipc);

    ConnectionEvent ce2 = new ConnectionEvent(ipc, null);
    assertNull(ce.getSQLException());
    assertEquals(ce2.getSQLException(), ce.getSQLException());

    SQLException e = new SQLException();
    ConnectionEvent ce3 = new ConnectionEvent(ipc, e);
    assertNotNull(ce3.getSQLException());
    assertNotSame(ce3.getSQLException(), ce2.getSQLException());

}
项目:In-the-Box-Fork    文件:ConnectionEventTest.java   
@TestTargetNew(
        level = TestLevel.SUFFICIENT,
        notes = "",
        method = "!Serialization",
        args = {}
)
public void testSerializationCompatibility() throws Exception {
    Impl_PooledConnection ipc = new Impl_PooledConnection();
    SQLException nextSQLException = new SQLException("nextReason",
            "nextSQLState", 33);

    int vendorCode = 10;
    SQLException sqlException = new SQLException("reason", "SQLState",
            vendorCode);

    sqlException.setNextException(nextSQLException);

    ConnectionEvent ce = new ConnectionEvent(ipc, sqlException);

    SerializationTest.verifyGolden(this, ce, CONNECTIONEVENT_COMPARATOR);
}
项目:In-the-Box-Fork    文件:ConnectionEventTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {
    ConnectionEvent ceInitial = (ConnectionEvent) initial;
    ConnectionEvent ceDeser = (ConnectionEvent) deserialized;

    SQLException initThr = ceInitial.getSQLException();
    SQLException dserThr = ceDeser.getSQLException();

    // verify SQLState
    assertEquals(initThr.getSQLState(), dserThr.getSQLState());

    // verify vendorCode
    assertEquals(initThr.getErrorCode(), dserThr.getErrorCode());

    // verify next
    if (initThr.getNextException() == null) {
        assertNull(dserThr.getNextException());
    }
}
项目:indoor-tracking    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType,
        SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this,
            sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener
                    .connectionErrorOccurred(connectionevent);
        }
    }
}
项目:cn1    文件:ConnectionEventTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {
    Impl_PooledConnection ipc = new Impl_PooledConnection();
    SQLException nextSQLException = new SQLException("nextReason",
            "nextSQLState", 33);

    int vendorCode = 10;
    SQLException sqlException = new SQLException("reason", "SQLState",
            vendorCode);

    sqlException.setNextException(nextSQLException);

    ConnectionEvent ce = new ConnectionEvent(ipc, sqlException);

    SerializationTest.verifyGolden(this, ce, CONNECTIONEVENT_COMPARATOR);
}
项目:cn1    文件:ConnectionEventTest.java   
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {
    ConnectionEvent ceInitial = (ConnectionEvent) initial;
    ConnectionEvent ceDeser = (ConnectionEvent) deserialized;

    SQLException initThr = ceInitial.getSQLException();
    SQLException dserThr = ceDeser.getSQLException();

    // verify SQLState
    assertEquals(initThr.getSQLState(), dserThr.getSQLState());

    // verify vendorCode
    assertEquals(initThr.getErrorCode(), dserThr.getErrorCode());

    // verify next
    if (initThr.getNextException() == null) {
        assertNull(dserThr.getNextException());
    }
}
项目:SMPT42    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:ForYou    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType,
        SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this,
            sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener
                    .connectionErrorOccurred(connectionevent);
        }
    }
}
项目:group-five    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:locaviewer    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:locaviewer    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType, SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this, sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener.connectionErrorOccurred(connectionevent);
        }
    }
}
项目:manydesigns.cn    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType,
        SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this,
            sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener
                    .connectionErrorOccurred(connectionevent);
        }
    }
}
项目:Gladiatus    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType,
        SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this,
            sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener
                    .connectionErrorOccurred(connectionevent);
        }
    }
}
项目:Jspad    文件:MysqlPooledConnection.java   
/**
 * Notifies all registered ConnectionEventListeners of ConnectionEvents.
 * Instantiates a new ConnectionEvent which wraps sqlException and invokes
 * either connectionClose or connectionErrorOccurred on listener as
 * appropriate.
 * 
 * @param eventType
 *            value indicating whether connectionClosed or
 *            connectionErrorOccurred called
 * @param sqlException
 *            the exception being thrown
 */
protected synchronized void callConnectionEventListeners(int eventType,
        SQLException sqlException) {

    if (this.connectionEventListeners == null) {

        return;
    }

    Iterator<Map.Entry<ConnectionEventListener, ConnectionEventListener>> iterator = this.connectionEventListeners.entrySet().iterator();

    ConnectionEvent connectionevent = new ConnectionEvent(this,
            sqlException);

    while (iterator.hasNext()) {

        ConnectionEventListener connectioneventlistener = iterator.next().getValue();

        if (eventType == CONNECTION_CLOSED_EVENT) {
            connectioneventlistener.connectionClosed(connectionevent);
        } else if (eventType == CONNECTION_ERROR_EVENT) {
            connectioneventlistener
                    .connectionErrorOccurred(connectionevent);
        }
    }
}