Java Code Examples for javax.sql.ConnectionEventListener

The following examples show how to use javax.sql.ConnectionEventListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lams   Source File: MysqlPooledConnection.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 2
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 3
Source Project: r-course   Source File: MysqlPooledConnection.java    License: MIT License 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 4
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 5
Source Project: gemfirexd-oss   Source File: ClientPooledConnection.java    License: Apache License 2.0 6 votes vote down vote up
public synchronized void addConnectionEventListener(
                                        ConnectionEventListener listener) {
    if (logWriter_ != null) {
        logWriter_.traceEntry(this, "addConnectionEventListener", listener);
    }

    if (listener == null) {
        // Ignore the listener if it is null. Otherwise, an exception is
        // thrown when a connection event occurs (DERBY-3307).
        return;
    }

    if (eventIterators > 0) {
        // DERBY-3401: Someone is iterating over the ArrayList, and since
        // we were able to synchronize on this, that someone is us. Clone
        // the list of listeners in order to prevent invalidation of the
        // iterator.
        listeners_ = (ArrayList) listeners_.clone();
    }
    listeners_.add(listener);
}
 
Example 6
Source Project: gemfirexd-oss   Source File: ClientPooledConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 7
Source Project: gemfirexd-oss   Source File: EmbedPooledConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 8
Source Project: gemfirexd-oss   Source File: TranxPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  
 */
@Override
void destroyPooledConnection(Object connectionObject) {
  try {
    ((PooledConnection) connectionObject)
        .removeConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    ((PooledConnection) connectionObject).close();
    connectionObject = null;
  }
  catch (Exception ex) {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.finerEnabled())
        writer
            .finer(
                "AbstractPoolcache::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is "
                    + ex.toString(), ex);
  }
}
 
Example 9
Source Project: gemfirexd-oss   Source File: TranxPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new connection for the pool. This connection can participate in
 * the transactions.
 * 
 * @return the connection from the database as PooledConnection object.
 */
@Override
public Object getNewPoolConnection() throws PoolException {
  if (m_xads != null) {
    PooledConnection poolConn = null;
    try {
      poolConn = m_xads.getXAConnection(configProps.getUser(), configProps
          .getPassword());
    }
    catch (SQLException sqx) {
      throw new PoolException(LocalizedStrings.TranxPoolCacheImpl_TRANXPOOLCACHEIMPLGETNEWCONNECTION_EXCEPTION_IN_CREATING_NEW_TRANSACTION_POOLEDCONNECTION.toLocalizedString(), sqx);
    }
    poolConn
        .addConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    return poolConn;
  }
  else {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.fineEnabled()) writer.fine("TranxPoolCacheImpl::getNewConnection: ConnectionPoolCache not intialized with XADatasource");
    throw new PoolException(LocalizedStrings.TranxPoolCacheImpl_TRANXPOOLCACHEIMPLGETNEWCONNECTION_CONNECTIONPOOLCACHE_NOT_INTIALIZED_WITH_XADATASOURCE.toLocalizedString());
  }
}
 
Example 10
Source Project: gemfirexd-oss   Source File: ConnectionPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This method destroys the connection.
 */
@Override
void destroyPooledConnection(Object connectionObject) {
  try {
    ((PooledConnection) connectionObject)
        .removeConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    ((PooledConnection) connectionObject).close();
    connectionObject = null;
  }
  catch (Exception ex) {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.finerEnabled())
        writer
            .finer(
                "AbstractPoolcache::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is "
                    + ex.toString(), ex);
  }
}
 
Example 11
Source Project: gemfirexd-oss   Source File: ConnectionPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new connection for the pool.
 * 
 * @return the connection from the database as Object.
 * @throws PoolException
 */
@Override
public Object getNewPoolConnection() throws PoolException {
  if (m_cpds != null) {
    PooledConnection poolConn = null;
    try {
      poolConn = m_cpds.getPooledConnection(configProps.getUser(),
          configProps.getPassword());
    }
    catch (SQLException sqx) {
      throw new PoolException(LocalizedStrings.ConnectionPoolCacheImpl_CONNECTIONPOOLCACHEIMPLGENEWCONNECTION_EXCEPTION_IN_CREATING_NEW_POOLEDCONNECTION.toLocalizedString(), sqx);
    }
    poolConn
        .addConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    return poolConn;
  }
  else {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.fineEnabled()) writer.fine("ConnectionPoolCacheImpl::geNewConnection: ConnectionPoolCache not intialized with ConnectionPoolDatasource");
    throw new PoolException(LocalizedStrings.ConnectionPoolCacheImpl_CONNECTIONPOOLCACHEIMPLGENEWCONNECTION_CONNECTIONPOOLCACHE_NOT_INTIALIZED_WITH_CONNECTIONPOOLDATASOURCE.toLocalizedString());
  }
}
 
Example 12
/**
 * 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);
        }
    }
}
 
Example 13
/**
 * Closing a logical connection by obtaining a new logical connection should
 * not fire a connectionClosed to the listener
 * 
 * @throws SQLException
 */
@SuppressWarnings("unused")
@Test
public void testClosingLogicalByObtainingNewDoesNotFireConnectionClosed() throws SQLException {
    final Connection physical = context.mock(Connection.class);
    final FBPooledConnection pooled = new FBPooledConnection(physical);
    final ConnectionEventListener cel = context.mock(ConnectionEventListener.class);
    pooled.addConnectionEventListener(cel);

    context.checking(new Expectations() {
        {
            ignoring(physical);
            never(cel).connectionClosed(with(any(ConnectionEvent.class)));
        }
    });

    Connection logical1 = pooled.getConnection();
    Connection logical2 = pooled.getConnection();
}
 
Example 14
Source Project: gemfirexd-oss   Source File: EmbedPooledConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 15
Source Project: gemfirexd-oss   Source File: TranxPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  
 */
@Override
void destroyPooledConnection(Object connectionObject) {
  try {
    ((PooledConnection) connectionObject)
        .removeConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    ((PooledConnection) connectionObject).close();
    connectionObject = null;
  }
  catch (Exception ex) {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.finerEnabled())
        writer
            .finer(
                "AbstractPoolcache::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is "
                    + ex.toString(), ex);
  }
}
 
Example 16
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_t.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 17
Source Project: gemfirexd-oss   Source File: ConnectionPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This method destroys the connection.
 */
@Override
void destroyPooledConnection(Object connectionObject) {
  try {
    ((PooledConnection) connectionObject)
        .removeConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    ((PooledConnection) connectionObject).close();
    connectionObject = null;
  }
  catch (Exception ex) {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.finerEnabled())
        writer
            .finer(
                "AbstractPoolcache::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is "
                    + ex.toString(), ex);
  }
}
 
Example 18
Source Project: gemfirexd-oss   Source File: ConnectionPoolCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new connection for the pool.
 * 
 * @return the connection from the database as Object.
 * @throws PoolException
 */
@Override
public Object getNewPoolConnection() throws PoolException {
  if (m_cpds != null) {
    PooledConnection poolConn = null;
    try {
      poolConn = m_cpds.getPooledConnection(configProps.getUser(),
          configProps.getPassword());
    }
    catch (SQLException sqx) {
      throw new PoolException(LocalizedStrings.ConnectionPoolCacheImpl_CONNECTIONPOOLCACHEIMPLGENEWCONNECTION_EXCEPTION_IN_CREATING_NEW_POOLEDCONNECTION.toLocalizedString(), sqx);
    }
    poolConn
        .addConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
    return poolConn;
  }
  else {
    LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
    if (writer.fineEnabled()) writer.fine("ConnectionPoolCacheImpl::geNewConnection: ConnectionPoolCache not intialized with ConnectionPoolDatasource");
    throw new PoolException(LocalizedStrings.ConnectionPoolCacheImpl_CONNECTIONPOOLCACHEIMPLGENEWCONNECTION_CONNECTIONPOOLCACHE_NOT_INTIALIZED_WITH_CONNECTIONPOOLDATASOURCE.toLocalizedString());
  }
}
 
Example 19
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 20
/**
 * Explicitly closing a logical connection should fire a connectionClosed to
 * the listener with the PooledConnection as source.
 * 
 * @throws SQLException
 */
@Test
public void testClosingLogicalFiresConnectionClosed() throws SQLException {
    final Connection physical = context.mock(Connection.class);
    final FBPooledConnection pooled = new FBPooledConnection(physical);
    final ConnectionEventListener cel = context.mock(ConnectionEventListener.class);
    pooled.addConnectionEventListener(cel);

    context.checking(new Expectations() {
        {
            ignoring(physical);
            oneOf(cel).connectionClosed(
                    with(new ConnectionEventMatcher(pooled, aNull(SQLException.class))));
        }
    });

    Connection logical = pooled.getConnection();
    logical.close();
}
 
Example 21
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 22
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_t.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 23
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 24
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_t.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 25
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 26
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_t.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 27
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 28
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 29
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_s.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}
 
Example 30
Source Project: coming   Source File: 1205753_EmbedPooledConnection_0_t.java    License: MIT License 6 votes vote down vote up
/**
 * 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--;
        }
    }
}