mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
添加ExceptionSorter
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@309 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -106,7 +106,7 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
protected PrintWriter logWriter = new PrintWriter(System.out);
|
||||
|
||||
protected List<Filter> filters = new ArrayList<Filter>();
|
||||
protected List<ExceptionSorter> exceptionSoters = new ArrayList<ExceptionSorter>();
|
||||
protected ExceptionSorter exceptionSoter = null;
|
||||
|
||||
protected Driver driver;
|
||||
|
||||
@@ -142,6 +142,8 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
|
||||
protected ValidConnectionChecker validConnectionChecker = null;
|
||||
|
||||
protected final AtomicLong errorCount = new AtomicLong();
|
||||
|
||||
public ValidConnectionChecker getValidConnectionChecker() {
|
||||
return validConnectionChecker;
|
||||
}
|
||||
@@ -636,28 +638,28 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public List<ExceptionSorter> getExceptionSoters() {
|
||||
return exceptionSoters;
|
||||
public ExceptionSorter getExceptionSoter() {
|
||||
return exceptionSoter;
|
||||
}
|
||||
|
||||
public void setExceptionSoters(List<ExceptionSorter> exceptionSoters) {
|
||||
this.exceptionSoters = exceptionSoters;
|
||||
public void setExceptionSoter(ExceptionSorter exceptionSoter) {
|
||||
this.exceptionSoter = exceptionSoter;
|
||||
}
|
||||
|
||||
public void setExceptionSoters(String exceptionSorters) throws Exception {
|
||||
this.exceptionSoters.clear();
|
||||
|
||||
if (exceptionSorters == null || exceptionSorters.length() == 0) {
|
||||
public void setExceptionSoter(String exceptionSorter) throws Exception {
|
||||
if (exceptionSorter == null) {
|
||||
this.exceptionSoter = null;
|
||||
return;
|
||||
}
|
||||
|
||||
String[] sorterArray = exceptionSorters.split("\\,");
|
||||
|
||||
for (String item : sorterArray) {
|
||||
Class<?> clazz = DruidLoaderUtils.loadClass(item);
|
||||
ExceptionSorter sorter = (ExceptionSorter) clazz.newInstance();
|
||||
exceptionSoters.add(sorter);
|
||||
exceptionSorter = exceptionSorter.trim();
|
||||
if (exceptionSorter.length() == 0) {
|
||||
this.exceptionSoter = null;
|
||||
return;
|
||||
}
|
||||
|
||||
Class<?> clazz = DruidLoaderUtils.loadClass(exceptionSorter);
|
||||
this.exceptionSoter = (ExceptionSorter) clazz.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -805,6 +807,10 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleException(Throwable e) throws SQLException {
|
||||
errorCount.incrementAndGet();
|
||||
}
|
||||
|
||||
protected abstract void recycle(PoolableConnection pooledConnection) throws SQLException;
|
||||
|
||||
abstract void incrementCreateCount();
|
||||
|
||||
Reference in New Issue
Block a user