You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2018/09/12 01:59:49 UTC
[kylin] 04/04: KYLIN-3557 PreparedStatement not closed in
JDBCResourceDAO
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 3f7b42acd1ef2b99f054cc958b310d1cd7b6784c
Author: shaofengshi <sh...@apache.org>
AuthorDate: Wed Sep 12 09:59:36 2018 +0800
KYLIN-3557 PreparedStatement not closed in JDBCResourceDAO
---
.../org/apache/kylin/common/persistence/JDBCResourceDAO.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java b/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java
index 9bf6c24..a226af6 100644
--- a/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java
+++ b/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java
@@ -40,6 +40,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.DBUtils;
import org.apache.kylin.common.util.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -441,10 +442,15 @@ public class JDBCResourceDAO {
private boolean checkTableExists(final String tableName, final Connection connection) throws SQLException {
final PreparedStatement ps = connection.prepareStatement(getCheckTableExistsSql(tableName));
final ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- if (tableName.equals(rs.getString(1))) {
- return true;
+ try {
+ while (rs.next()) {
+ if (tableName.equals(rs.getString(1))) {
+ return true;
+ }
}
+ } finally {
+ DBUtils.closeQuietly(rs);
+ DBUtils.closeQuietly(ps);
}
return false;