当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionEventListener.connectionClosed方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:19,代码来源:CloudSpannerPooledConnection.java

示例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);
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:35,代码来源:MysqlPooledConnection.java

示例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--;
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:32,代码来源:ClientPooledConnection.java

示例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--;
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:EmbedPooledConnection.java

示例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);
		}
	}
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:38,代码来源:MysqlPooledConnection.java

示例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));	
			}
		}
	}	
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:21,代码来源:XAConnectionImpl.java

示例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();
}
 
开发者ID:xionghuiCoder,项目名称:clearpool,代码行数:24,代码来源:PoolConnectionImpl.java

示例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--;
        }
    }
}
 
开发者ID:splicemachine,项目名称:spliceengine,代码行数:30,代码来源:ClientPooledConnection.java

示例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--;
        }
    }
}
 
开发者ID:splicemachine,项目名称:spliceengine,代码行数:28,代码来源:EmbedPooledConnection.java

示例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);
        }
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:14,代码来源:LifeTimeConnectionWrapper.java

示例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;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:JdbcXAConnection.java

示例12: connectionClosed

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
void connectionClosed()
{
	ConnectionEvent event = new ConnectionEvent(this);
	for (ConnectionEventListener listener : connectionEventListeners)
	{
		listener.connectionClosed(event);
	}
}
 
开发者ID:adejanovski,项目名称:cassandra-jdbc-wrapper,代码行数:9,代码来源:PooledCassandraConnection.java

示例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
}
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:13,代码来源:XAConnectionImpl.java

示例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);
		}
	}
}
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:12,代码来源:LocalXAConnection.java

示例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);
    }
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:9,代码来源:TesterBasicXAConnection.java


注:本文中的javax.sql.ConnectionEventListener.connectionClosed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。