validateConnection add exception cause

This commit is contained in:
高铁
2016-05-31 16:46:06 +08:00
parent 2f4bc706a1
commit ecfcd1116b
7 changed files with 72 additions and 136 deletions
@@ -1247,8 +1247,19 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
}
if (validConnectionChecker != null) {
if (!validConnectionChecker.isValidConnection(conn, validationQuery, validationQueryTimeout)) {
throw new SQLException("validateConnection false");
boolean result = true;
Exception error = null;
try {
result = validConnectionChecker.isValidConnection(conn, validationQuery, validationQueryTimeout);
} catch (Exception ex) {
error = ex;
}
if (!result) {
SQLException sqlError = error != null ? //
new SQLException("validateConnection false", error) //
: new SQLException("validateConnection false");
throw sqlError;
}
return;
}