diff --git a/taier-datasource/taier-datasource-plugin/taier-datasource-plugin-mysql5/src/main/java/com/dtstack/taier/datasource/plugin/mysql5/MysqlDownloader.java b/taier-datasource/taier-datasource-plugin/taier-datasource-plugin-mysql5/src/main/java/com/dtstack/taier/datasource/plugin/mysql5/MysqlDownloader.java index 3a2321eb0c..dcba324c77 100644 --- a/taier-datasource/taier-datasource-plugin/taier-datasource-plugin-mysql5/src/main/java/com/dtstack/taier/datasource/plugin/mysql5/MysqlDownloader.java +++ b/taier-datasource/taier-datasource-plugin/taier-datasource-plugin-mysql5/src/main/java/com/dtstack/taier/datasource/plugin/mysql5/MysqlDownloader.java @@ -88,12 +88,15 @@ public boolean configure() throws Exception { String countSQL = String.format("SELECT COUNT(*) FROM (%s) temp", sql); String showColumns = String.format("SELECT * FROM (%s) t limit 1", sql); - try (ResultSet totalResultSet = statement.executeQuery(countSQL); - ResultSet columnsResultSet = statement.executeQuery(showColumns)) { + ResultSet totalResultSet = null; + ResultSet columnsResultSet = null; + try { + totalResultSet = statement.executeQuery(countSQL); while (totalResultSet.next()) { //获取总行数 totalLine = totalResultSet.getInt(1); } + columnsResultSet = statement.executeQuery(showColumns); //获取列信息 columnNames = new ArrayList<>(); columnCount = columnsResultSet.getMetaData().getColumnCount(); @@ -108,6 +111,9 @@ public boolean configure() throws Exception { pageAll = (int) Math.ceil(totalLine / (double) pageSize); } catch (Exception e) { throw new SourceException("build Mysql downloader message exception : " + e.getMessage(), e); + } finally { + DBUtil.closeDBResources(totalResultSet, null, null); + DBUtil.closeDBResources(columnsResultSet, null, null); } return true; }