This commit is contained in:
wenshao
2011-12-26 18:09:06 +08:00
parent 18f1875e24
commit 11d3b2c4a1
10 changed files with 103 additions and 79 deletions
@@ -108,6 +108,9 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
private String initStackTrace;
private Throwable lastError;
private Throwable lastCreateError;
public DruidDataSource(){
}
@@ -123,6 +126,14 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
this.resetStatEnable = resetStatEnable;
}
public Throwable getLastCreateError() {
return lastCreateError;
}
public Throwable getLastError() {
return this.lastError;
}
public void restart() {
lock.lock();
try {
@@ -501,6 +512,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
final ConnectionHolder holder = pooledConnection.getConnectionHolder();
errorCount.incrementAndGet();
lastError = t;
if (t instanceof SQLException) {
SQLException sqlEx = (SQLException) t;
@@ -717,7 +729,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
if (notEmptyWaitThreadCount > notEmptyWaitThreadPeak) {
notEmptyWaitThreadPeak = notEmptyWaitThreadCount;
}
try {
long startEstimate = estimate;
estimate = notEmpty.awaitNanos(estimate); // signal by
@@ -864,10 +876,13 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
}
} catch (InterruptedException e) {
lastCreateError = e;
break;
} catch (RuntimeException e) {
lastCreateError = e;
LOG.error("create connection error", e);
} catch (Error e) {
lastCreateError = e;
LOG.error("create connection error", e);
break;
} finally {
@@ -1150,7 +1165,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
public int getNotEmptyWaitThreadCount() {
return notEmptyWaitThreadCount;
}
public int getNotEmptyWaitThreadPeak() {
lock.lock();
try {