Repository: kylin
Updated Branches:
  refs/heads/master 65eaaf79f -> 61ff3c310


KYLIN-2701 KYLIN-2658 fix unclosed jdbc statements


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/61ff3c31
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/61ff3c31
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/61ff3c31

Branch: refs/heads/master
Commit: 61ff3c310c5406a1133ccb287bb6989bd10a5efd
Parents: 65eaaf7
Author: shaofengshi <shaofeng...@apache.org>
Authored: Sat Jul 22 21:39:50 2017 +0800
Committer: shaofengshi <shaofeng...@apache.org>
Committed: Sat Jul 22 21:40:45 2017 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kylin/rest/service/QueryService.java  | 5 +++--
 .../main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java   | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/61ff3c31/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
index f42859d..3c97f88 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
@@ -857,9 +857,9 @@ public class QueryService extends BasicService {
             List<List<String>> results, List<SelectedColumnMeta> columnMetas) 
throws SQLException {
 
         CalcitePrepareImpl.KYLIN_ONLY_PREPARE.set(true);
-
+        PreparedStatement preparedStatement = null;
         try {
-            conn.prepareStatement(correctedSql);
+            preparedStatement = conn.prepareStatement(correctedSql);
             throw new IllegalStateException("Should have thrown 
OnlyPrepareEarlyAbortException");
         } catch (Exception e) {
             Throwable rootCause = ExceptionUtils.getRootCause(e);
@@ -891,6 +891,7 @@ public class QueryService extends BasicService {
             }
         } finally {
             CalcitePrepareImpl.KYLIN_ONLY_PREPARE.set(false);
+            DBUtils.closeQuietly(preparedStatement);
         }
 
         return getSqlResponse(isPushDown, results, columnMetas);

http://git-wip-us.apache.org/repos/asf/kylin/blob/61ff3c31/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
----------------------------------------------------------------------
diff --git 
a/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java 
b/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
index 25eacfc..7dc4e43 100644
--- a/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
+++ b/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
@@ -29,6 +29,7 @@ import java.util.UUID;
 
 import org.apache.hadoop.hive.ql.CommandNeedRetryException;
 import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.DBUtils;
 import org.apache.kylin.common.util.Pair;
 import org.apache.kylin.metadata.model.ColumnDesc;
 import org.apache.kylin.metadata.model.TableDesc;
@@ -232,6 +233,7 @@ public class JdbcExplorer implements 
ISourceMetadataExplorer, ISampleDataDeploye
         while (rs.next()){
             tableType = rs.getString(4);
         }
+        DBUtils.closeQuietly(rs);
         if (tableType!=null){
             tableDesc.setTableType(tableType);
         }else{
@@ -284,8 +286,8 @@ public class JdbcExplorer implements 
ISourceMetadataExplorer, ISampleDataDeploye
             cdesc.setId(String.valueOf(pos));
             columns.add(cdesc);
         }
-        
-        
+        DBUtils.closeQuietly(rs);
+
         tableDesc.setColumns(columns.toArray(new ColumnDesc[columns.size()]));
 
         TableExtDesc tableExtDesc = new TableExtDesc();

Reply via email to