Skip to content

Commit 1074c64

Browse files
author
Sunny
committedAug 7, 2024
[issue_1187][plugin] fix mysql download (#1187)
1 parent 470fae8 commit 1074c64

File tree

1 file changed

+8
-2
lines changed
  • taier-datasource/taier-datasource-plugin/taier-datasource-plugin-mysql5/src/main/java/com/dtstack/taier/datasource/plugin/mysql5

1 file changed

+8
-2
lines changed
 

‎taier-datasource/taier-datasource-plugin/taier-datasource-plugin-mysql5/src/main/java/com/dtstack/taier/datasource/plugin/mysql5/MysqlDownloader.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ public boolean configure() throws Exception {
8888
String countSQL = String.format("SELECT COUNT(*) FROM (%s) temp", sql);
8989
String showColumns = String.format("SELECT * FROM (%s) t limit 1", sql);
9090

91-
try (ResultSet totalResultSet = statement.executeQuery(countSQL);
92-
ResultSet columnsResultSet = statement.executeQuery(showColumns)) {
91+
ResultSet totalResultSet = null;
92+
ResultSet columnsResultSet = null;
93+
try {
94+
totalResultSet = statement.executeQuery(countSQL);
9395
while (totalResultSet.next()) {
9496
//获取总行数
9597
totalLine = totalResultSet.getInt(1);
9698
}
99+
columnsResultSet = statement.executeQuery(showColumns);
97100
//获取列信息
98101
columnNames = new ArrayList<>();
99102
columnCount = columnsResultSet.getMetaData().getColumnCount();
@@ -108,6 +111,9 @@ public boolean configure() throws Exception {
108111
pageAll = (int) Math.ceil(totalLine / (double) pageSize);
109112
} catch (Exception e) {
110113
throw new SourceException("build Mysql downloader message exception : " + e.getMessage(), e);
114+
} finally {
115+
DBUtil.closeDBResources(totalResultSet, null, null);
116+
DBUtil.closeDBResources(columnsResultSet, null, null);
111117
}
112118
return true;
113119
}

0 commit comments

Comments
 (0)