Skip to content

Commit

Permalink
[issue_1187][plugin] fix mysql download (#1187) (#1188)
Browse files Browse the repository at this point in the history
Co-authored-by: Sunny <[email protected]>
  • Loading branch information
QAQ-Jun and Sunny authored Aug 7, 2024
1 parent 470fae8 commit deee65d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down

0 comments on commit deee65d

Please sign in to comment.