From 37efd234f6a955e026eba0f0579ab6a63f3fd71c Mon Sep 17 00:00:00 2001 From: vran Date: Thu, 21 Apr 2022 13:26:23 +0800 Subject: [PATCH] fix: cursor over limit when sync (#115) --- .../impl/jdbc/JdbcColumnMetaRepository.java | 14 +++++++++----- .../impl/jdbc/JdbcForeignKeyMetaRepository.java | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java index 090709a..7ca7661 100644 --- a/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java @@ -94,11 +94,15 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository { TableCondition tableCondition) throws SQLException { ResultSet result = meta.getPrimaryKeys(tableCondition.getDatabaseName(), tableCondition.getSchemaName(), tableCondition.getTableName()); - List columns = new ArrayList<>(); - while (result.next()) { - String columnName = result.getString("COLUMN_NAME"); - columns.add(columnName); + try { + List columns = new ArrayList<>(); + while (result.next()) { + String columnName = result.getString("COLUMN_NAME"); + columns.add(columnName); + } + return columns; + } finally { + result.close(); } - return columns; } } diff --git a/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java index 0fef5a8..6bbdc4f 100644 --- a/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcForeignKeyMetaRepository.java @@ -52,7 +52,9 @@ public class JdbcForeignKeyMetaRepository implements ForeignKeyMetaRepository { log.warn("warn: ignore foreign keys in " + databaseName + "." + tableName + ", " + e.getMessage()); } finally { try { - keyResult.close(); + if (keyResult != null) { + keyResult.close(); + } } catch (SQLException e) { log.warn("warn: close key result error " + databaseName + "." + tableName + ", " + e.getMessage()); }