mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
代码重构
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@619 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -33,6 +33,8 @@ import javax.naming.NamingException;
|
||||
import javax.naming.Reference;
|
||||
import javax.naming.Referenceable;
|
||||
import javax.naming.StringRefAddr;
|
||||
import javax.sql.ConnectionEvent;
|
||||
import javax.sql.ConnectionEventListener;
|
||||
|
||||
import com.alibaba.druid.filter.Filter;
|
||||
import com.alibaba.druid.logging.Log;
|
||||
@@ -331,6 +333,33 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
}
|
||||
return poolalbeConnection;
|
||||
}
|
||||
|
||||
public void handleConnectionException(PoolableConnection pooledConnection, Throwable t) throws SQLException {
|
||||
final ConnectionHolder holder = pooledConnection.getConnectionHolder();
|
||||
|
||||
errorCount.incrementAndGet();
|
||||
|
||||
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 (exceptionSoter != null && exceptionSoter.isExceptionFatal(sqlEx)) {
|
||||
decrementActiveCountWithLock();
|
||||
JdbcUtils.close(holder.getConnection());
|
||||
pooledConnection.disable();
|
||||
}
|
||||
|
||||
throw sqlEx;
|
||||
} else {
|
||||
throw new SQLException("Error", t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收连接
|
||||
|
||||
Reference in New Issue
Block a user