You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by xx...@apache.org on 2023/02/27 08:00:44 UTC
[kylin] 04/34: KYLIN-5445 fix connection
This is an automated email from the ASF dual-hosted git repository.
xxyu pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit b5c3fb16d441008c71dc56a56dff01419640deda
Author: jiawei.li <10...@qq.com>
AuthorDate: Sun Jan 8 10:41:54 2023 +0800
KYLIN-5445 fix connection
---
.../common/persistence/metadata/jdbc/JdbcUtil.java | 25 ++++++++++++----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java b/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java
index 5c24313fb2..1bd3883af8 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/persistence/metadata/jdbc/JdbcUtil.java
@@ -123,20 +123,23 @@ public class JdbcUtil {
}
private static boolean isPrimaryKeyExists(Connection conn, String... tables) throws SQLException {
-
- for (String table : tables) {
- try {
- val resultSet = conn.getMetaData().getPrimaryKeys(conn.getCatalog(), conn.getSchema(), table);
- if (resultSet.next()) {
- return true;
+ try {
+ for (String table : tables) {
+ try {
+ val resultSet = conn.getMetaData().getPrimaryKeys(conn.getCatalog(), conn.getSchema(), table);
+ if (resultSet.next()) {
+ return true;
+ }
+ } catch (Exception e) {
+ log.warn("get primary key from table {} failed", table, e);
}
- } catch (Exception e) {
- log.warn("get primary key from table {} failed", table, e);
+ }
+ } finally {
+ if (!conn.isClosed()) {
+ conn.close();
}
}
- if (!conn.isClosed()) {
- conn.close();
- }
+
return false;
}