From c117be5e40db0dd9eb8faab9c59ecd627205f858 Mon Sep 17 00:00:00 2001 From: ju Date: Sat, 13 Oct 2018 00:54:09 +0800 Subject: [PATCH] fix --- .../vendor/MSSQLValidConnectionChecker.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/fine-druid/src/com/fr/third/alibaba/druid/pool/vendor/MSSQLValidConnectionChecker.java b/fine-druid/src/com/fr/third/alibaba/druid/pool/vendor/MSSQLValidConnectionChecker.java index d7d5f9583..b021ecdcb 100644 --- a/fine-druid/src/com/fr/third/alibaba/druid/pool/vendor/MSSQLValidConnectionChecker.java +++ b/fine-druid/src/com/fr/third/alibaba/druid/pool/vendor/MSSQLValidConnectionChecker.java @@ -28,20 +28,25 @@ import com.fr.third.alibaba.druid.util.JdbcUtils; * A MSSQLValidConnectionChecker. */ public class MSSQLValidConnectionChecker extends ValidConnectionCheckerAdapter implements ValidConnectionChecker, Serializable { - + private static final long serialVersionUID = 1L; - - public MSSQLValidConnectionChecker(){ - + + public MSSQLValidConnectionChecker() { + } - + public boolean isValidConnection(final Connection c, String validateQuery, int validationQueryTimeout) throws Exception { + if (c.isClosed()) { return false; } - + + if (validateQuery == null || validateQuery.isEmpty()) { + validateQuery = "select 1"; + } + Statement stmt = null; - + try { stmt = c.createStatement(); if (validationQueryTimeout > 0) { @@ -55,5 +60,5 @@ public class MSSQLValidConnectionChecker extends ValidConnectionCheckerAdapter i JdbcUtils.close(stmt); } } - -} + +} \ No newline at end of file