本文整理汇总了Java中javax.sql.ConnectionEventListener.connectionClosed方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionEventListener.connectionClosed方法的具体用法?Java ConnectionEventListener.connectionClosed怎么用?Java ConnectionEventListener.connectionClosed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sql.ConnectionEventListener
的用法示例。
在下文中一共展示了ConnectionEventListener.connectionClosed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fireConnectionClosed
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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);
}
}
示例2: callConnectionEventListeners
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例3: fireConnectionEventListeners
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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--;
}
}
}
示例4: fireConnectionEventListeners
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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--;
}
}
}
示例5: callConnectionEventListeners
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例6: notifyListener
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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));
}
}
}
}
示例7: close
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
@Override
public void close() throws SQLException {
if (this.isClosed) {
return;
}
this.isClosed = true;
for (Statement stmt : this.statementSet) {
stmt.close();
}
this.statementSet.clear();
if (this.connectionEventListeners != null) {
ConnectionEvent event = new ConnectionEvent(this);
for (ConnectionEventListener listener : this.connectionEventListeners) {
listener.connectionClosed(event);
}
this.connectionEventListeners = null;
}
if (this.statementEventListeners != null) {
this.statementEventListeners = null;
}
this.connection = null;
this.conProxy.close();
}
示例8: fireConnectionEventListeners
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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());
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--;
}
}
}
示例9: fireConnectionEventListeners
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* 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 (Object anEventListener : eventListener) {
ConnectionEventListener l =
(ConnectionEventListener) anEventListener;
if (exception == null) {
l.connectionClosed(event);
} else {
l.connectionErrorOccurred(event);
}
}
} finally {
eventIterators--;
}
}
}
示例10: fireCloseEvent
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
protected void fireCloseEvent() {
ConnectionEvent connectionEvent =
new ConnectionEvent(this.pooledConnection);
for (Iterator iterator = connectionListeners.iterator();
iterator.hasNext(); ) {
ConnectionEventListener connectionListener =
(ConnectionEventListener) iterator.next();
connectionListener.connectionClosed(connectionEvent);
}
}
示例11: closedHandle
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
* INTERNAL
*/
void closedHandle() {
debugCode("closedHandle();");
ConnectionEvent event = new ConnectionEvent(this);
// go backward so that a listener can remove itself
// (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;
}
示例12: connectionClosed
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
void connectionClosed()
{
ConnectionEvent event = new ConnectionEvent(this);
for (ConnectionEventListener listener : connectionEventListeners)
{
listener.connectionClosed(event);
}
}
示例13: connectionClosed
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
public void connectionClosed(ConnectionEvent event) {
for (Iterator<ConnectionEventListener> itr = this.listeners.iterator(); itr.hasNext();) {
ConnectionEventListener listener = itr.next();
try {
listener.connectionClosed(new ConnectionEvent(this, event.getSQLException()));
} catch (RuntimeException rex) {
logger.warn(rex.getMessage(), rex);
}
} // end-for (Iterator<ConnectionEventListener> itr = this.listeners.iterator(); itr.hasNext();)
this.firePhysicalConnectionClosed(event); // removeConnectionEventListener
}
示例14: fireConnectionClosed
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
private void fireConnectionClosed() {
Iterator<ConnectionEventListener> itr = this.listeners.iterator();
while (itr.hasNext()) {
ConnectionEventListener listener = itr.next();
try {
listener.connectionClosed(new ConnectionEvent(this));
} catch (Exception ex) {
logger.debug(ex.getMessage(), ex);
}
}
}
示例15: notifyConnectionClosed
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
protected void notifyConnectionClosed() {
final ConnectionEvent event = new ConnectionEvent(this);
final List<ConnectionEventListener> copy = new ArrayList<>(
listeners);
for (final ConnectionEventListener listener : copy) {
listener.connectionClosed(event);
}
}