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


Java ConnectionEventListener.connectionErrorOccurred方法代码示例

本文整理汇总了Java中javax.sql.ConnectionEventListener.connectionErrorOccurred方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionEventListener.connectionErrorOccurred方法的具体用法?Java ConnectionEventListener.connectionErrorOccurred怎么用?Java ConnectionEventListener.connectionErrorOccurred使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sql.ConnectionEventListener的用法示例。


在下文中一共展示了ConnectionEventListener.connectionErrorOccurred方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fireConnectionFatalError

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
/**
 * 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);
	}
}
 
开发者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: 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

示例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 (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

示例9: fireSqlExceptionEvent

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
protected void fireSqlExceptionEvent(SQLException e) {

        ConnectionEvent event = new ConnectionEvent(this.pooledConnection, e);

        for (Iterator iterator = connectionListeners.iterator();
                iterator.hasNext(); ) {
            ConnectionEventListener connectionEventListener =
                (ConnectionEventListener) iterator.next();

            connectionEventListener.connectionErrorOccurred(event);
        }
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:13,代码来源:LifeTimeConnectionWrapper.java

示例10: connectionErrorOccurred

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

示例11: connectionErrorOccurred

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
public void connectionErrorOccurred(ConnectionEvent event) {
	for (Iterator<ConnectionEventListener> itr = this.listeners.iterator(); itr.hasNext();) {
		ConnectionEventListener listener = itr.next();
		try {
			listener.connectionErrorOccurred(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

示例12: fireConnectionErrorOccurred

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
private void fireConnectionErrorOccurred() {
	Iterator<ConnectionEventListener> itr = this.listeners.iterator();
	while (itr.hasNext()) {
		ConnectionEventListener listener = itr.next();
		try {
			listener.connectionErrorOccurred(new ConnectionEvent(this));
		} catch (Exception ex) {
			logger.debug(ex.getMessage(), ex);
		}
	}
}
 
开发者ID:liuyangming,项目名称:ByteJTA,代码行数:12,代码来源:LocalXAConnection.java

示例13: handleException

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
private SQLException handleException(SQLException e) throws SQLException {
  ConnectionEvent event = new ConnectionEvent(this, e);
  if (this.connectionEventListeners != null) {
    for (ConnectionEventListener eventListener : this.connectionEventListeners) {
      eventListener.connectionErrorOccurred(event);
    }
  }
  throw e;
}
 
开发者ID:xionghuiCoder,项目名称:clearpool,代码行数:10,代码来源:PoolConnectionImpl.java

示例14: notifyConnectionErrorOccurred

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
protected void notifyConnectionErrorOccurred(final SQLException e) {
    final ConnectionEvent event = new ConnectionEvent(this, e);
    final List<ConnectionEventListener> copy = new ArrayList<>(
            listeners);
    for (final ConnectionEventListener listener : copy) {
        listener.connectionErrorOccurred(event);
    }
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:9,代码来源:TesterBasicXAConnection.java

示例15: handleConnectionException

import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
public void handleConnectionException(DruidPooledConnection pooledConnection, Throwable t) throws SQLException {
    final DruidConnectionHolder holder = pooledConnection.getConnectionHolder();

    errorCount.incrementAndGet();
    lastError = t;
    lastErrorTimeMillis = System.currentTimeMillis();

    if (t instanceof SQLException) {
        SQLException sqlEx = (SQLException) t;

        // broadcastConnectionError
        ConnectionEvent event = new ConnectionEvent(pooledConnection, sqlEx);
        for (ConnectionEventListener eventListener : holder.getConnectionEventListeners()) {
            eventListener.connectionErrorOccurred(event);
        }

        // exceptionSorter.isExceptionFatal
        if (exceptionSorter != null && exceptionSorter.isExceptionFatal(sqlEx)) {
            if (pooledConnection.isTraceEnable()) {
                synchronized (activeConnections) {
                    if (pooledConnection.isTraceEnable()) {
                        activeConnections.remove(pooledConnection);
                        pooledConnection.setTraceEnable(false);
                    }
                }
            }

            boolean requireDiscard = false;
            synchronized (pooledConnection) {
                if ((!pooledConnection.isClosed()) || !pooledConnection.isDisable()) {
                    holder.setDiscard(true);
                    pooledConnection.disable(t);
                    requireDiscard = true;
                }
            }

            if (requireDiscard) {
                this.discardConnection(holder.getConnection());
                holder.setDiscard(true);
            }

            LOG.error("discard connection", sqlEx);
        }

        throw sqlEx;
    } else {
        throw new SQLException("Error", t);
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:50,代码来源:ElasticSearchDruidDataSource.java


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