mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
修正PG的校验器问题
修正stmt未设置查询超时的问题
This commit is contained in:
@@ -30,6 +30,8 @@ public class PGValidConnectionChecker extends ValidConnectionCheckerAdapter impl
|
||||
|
||||
private static final long serialVersionUID = -2227528634302168877L;
|
||||
|
||||
private int defaultQueryTimeout = 1;
|
||||
|
||||
private String defaultValidateQuery = "SELECT 'x'";
|
||||
|
||||
public PGValidConnectionChecker(){
|
||||
@@ -53,10 +55,13 @@ public class PGValidConnectionChecker extends ValidConnectionCheckerAdapter impl
|
||||
conn = ((ConnectionProxy) conn).getRawObject();
|
||||
}
|
||||
|
||||
int queryTimeout = validationQueryTimeout < 0 ? defaultQueryTimeout : validationQueryTimeout;
|
||||
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
stmt.setQueryTimeout(queryTimeout);
|
||||
rs = stmt.executeQuery(validateQuery);
|
||||
return true;
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user