mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+6
-4
@@ -33,7 +33,8 @@ import com.alibaba.druid.util.Utils;
|
||||
|
||||
public class MySqlValidConnectionChecker extends ValidConnectionCheckerAdapter implements ValidConnectionChecker, Serializable {
|
||||
|
||||
public static final int DEFAULT_VALIDATION_QUERY_TIMEOUT = 1000;
|
||||
public static final int DEFAULT_VALIDATION_QUERY_TIMEOUT = 1;
|
||||
public static final String DEFAULT_VALIDATION_QUERY = "SELECT 1";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log LOG = LogFactory.getLog(MySqlValidConnectionChecker.class);
|
||||
@@ -105,8 +106,9 @@ public class MySqlValidConnectionChecker extends ValidConnectionCheckerAdapter i
|
||||
}
|
||||
}
|
||||
|
||||
if (validateQuery == null || validateQuery.length() == 0) {
|
||||
return true;
|
||||
String query = validateQuery;
|
||||
if (validateQuery == null || validateQuery.isEmpty()) {
|
||||
query = DEFAULT_VALIDATION_QUERY;
|
||||
}
|
||||
|
||||
Statement stmt = null;
|
||||
@@ -116,7 +118,7 @@ public class MySqlValidConnectionChecker extends ValidConnectionCheckerAdapter i
|
||||
if (validationQueryTimeout > 0) {
|
||||
stmt.setQueryTimeout(validationQueryTimeout);
|
||||
}
|
||||
rs = stmt.executeQuery(validateQuery);
|
||||
rs = stmt.executeQuery(query);
|
||||
return true;
|
||||
} finally {
|
||||
JdbcUtils.close(rs);
|
||||
|
||||
+4
-2
@@ -70,15 +70,17 @@ public class OracleValidConnectionChecker extends ValidConnectionCheckerAdapter
|
||||
conn = ((ConnectionProxy) conn).getRawObject();
|
||||
}
|
||||
|
||||
if (validateQuery == null || validateQuery.length() == 0) {
|
||||
if (validateQuery == null || validateQuery.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int queryTimeout = validationQueryTimeout < 0 ? timeout : validationQueryTimeout;
|
||||
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
stmt.setQueryTimeout(timeout);
|
||||
stmt.setQueryTimeout(queryTimeout);
|
||||
rs = stmt.executeQuery(validateQuery);
|
||||
return true;
|
||||
} finally {
|
||||
|
||||
@@ -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