mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
完善mock和测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@837 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -799,7 +799,7 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateConnection(Connection conn) throws SQLException {
|
||||
public void validateConnection(Connection conn) throws SQLException {
|
||||
String query = getValidationQuery();
|
||||
if (conn.isClosed()) {
|
||||
throw new SQLException("validateConnection: connection closed");
|
||||
@@ -814,31 +814,19 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
|
||||
if (null != query) {
|
||||
Statement stmt = null;
|
||||
ResultSet rset = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
if (getValidationQueryTimeout() > 0) {
|
||||
stmt.setQueryTimeout(getValidationQueryTimeout());
|
||||
}
|
||||
rset = stmt.executeQuery(query);
|
||||
if (!rset.next()) {
|
||||
rs = stmt.executeQuery(query);
|
||||
if (!rs.next()) {
|
||||
throw new SQLException("validationQuery didn't return a row");
|
||||
}
|
||||
} finally {
|
||||
if (rset != null) {
|
||||
try {
|
||||
rset.close();
|
||||
} catch (Exception t) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (Exception t) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
JdbcUtils.close(rs);
|
||||
JdbcUtils.close(stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user