本文整理汇总了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);
}
}
示例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: 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--;
}
}
}
示例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--;
}
}
}
示例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);
}
}
示例10: connectionErrorOccurred
import javax.sql.ConnectionEventListener; //导入方法依赖的package包/类
void connectionErrorOccurred(SQLException sqlException)
{
ConnectionEvent event = new ConnectionEvent(this, sqlException);
for (ConnectionEventListener listener : connectionEventListeners)
{
listener.connectionErrorOccurred(event);
}
}
示例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
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}