use of javax.sql.ConnectionEvent in project voltdb by VoltDB.
the class LifeTimeConnectionWrapper method fireCloseEvent.
protected void fireCloseEvent() {
ConnectionEvent connectionEvent = new ConnectionEvent(this.pooledConnection);
for (Iterator iterator = connectionListeners.iterator(); iterator.hasNext(); ) {
ConnectionEventListener connectionListener = (ConnectionEventListener) iterator.next();
connectionListener.connectionClosed(connectionEvent);
}
}
use of javax.sql.ConnectionEvent in project datanucleus-rdbms by datanucleus.
the class PooledConnectionImpl method notifyListeners.
/**
* Sends a connectionClosed event.
*/
void notifyListeners() {
final ConnectionEvent event = new ConnectionEvent(this);
final Object[] listeners = eventListeners.toArray();
for (final Object listener : listeners) {
((ConnectionEventListener) listener).connectionClosed(event);
}
}
use of javax.sql.ConnectionEvent in project mssql-jdbc by Microsoft.
the class SQLServerPooledConnection method notifyEvent.
// Notify any interested parties (e.g. pooling managers) of a ConnectionEvent activity
// on the connection. Calling notifyEvent with null event will place the
// connection back in the pool. Calling notifyEvent with a non-null event is
// used to notify the pooling manager that the connection is bad and should be removed
// from the pool.
void notifyEvent(SQLServerException e) {
if (pcLogger.isLoggable(Level.FINER))
pcLogger.finer(toString() + " Exception:" + e + safeCID());
// close the proxy on fatal error event. Note exception is null then the event comes from the proxy close.
if (null != e) {
synchronized (this) {
if (null != lastProxyConnection) {
lastProxyConnection.internalClose();
lastProxyConnection = null;
}
}
}
// A connection handle issued from this pooled connection is closing or an error occurred in the connection
synchronized (listeners) {
for (int i = 0; i < listeners.size(); i++) {
ConnectionEventListener listener = listeners.elementAt(i);
if (listener == null)
continue;
ConnectionEvent ev = new ConnectionEvent(this, e);
if (null == e) {
if (pcLogger.isLoggable(Level.FINER))
pcLogger.finer(toString() + " notifyEvent:connectionClosed " + safeCID());
listener.connectionClosed(ev);
} else {
if (pcLogger.isLoggable(Level.FINER))
pcLogger.finer(toString() + " notifyEvent:connectionErrorOccurred " + safeCID());
listener.connectionErrorOccurred(ev);
}
}
}
}
use of javax.sql.ConnectionEvent in project h2database by h2database.
the class JdbcXAConnection method closedHandle.
/**
* INTERNAL
*/
void closedHandle() {
debugCode("closedHandle();");
ConnectionEvent event = new ConnectionEvent(this);
// (otherwise we need to clone the list)
for (int i = listeners.size() - 1; i >= 0; i--) {
ConnectionEventListener listener = listeners.get(i);
listener.connectionClosed(event);
}
handleConn = null;
}
use of javax.sql.ConnectionEvent in project derby by apache.
the class EmbedPooledConnection method fireConnectionEventListeners.
/**
* 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 (ConnectionEventListener l : eventListener) {
if (exception == null) {
l.connectionClosed(event);
} else {
l.connectionErrorOccurred(event);
}
}
} finally {
eventIterators--;
}
}
}
Aggregations