Skip to content

Commit

Permalink
ResultSe not closed in QueryRunner.insertBatch(Connection, String,
Browse files Browse the repository at this point in the history
ResultSetHandler, Object[][]).
  • Loading branch information
garydgregory committed Jul 31, 2023
1 parent 2b43139 commit d563207
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" due-to="Gary Gregory" type="fix">
ResultSet not closed in QueryRunner.insert(Connection, String, ResultSetHandler, Object...).
</action>
<action dev="ggregory" due-to="Gary Gregory" type="fix">
ResultSet not closed in QueryRunner.insertBatch(Connection, String, ResultSetHandler, Object[][]).
</action>
<!-- ADD -->
<action dev="thecarlhall" type="add" issue="PR/9" due-to="rewerma">
Add @Column annotation to hint the field name instead of dissecting the get method name.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/commons/dbutils/QueryRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ public <T> T insertBatch(final Connection conn, final String sql, final ResultSe
stmt.addBatch();
}
stmt.executeBatch();
final ResultSet rs = stmt.getGeneratedKeys();
generatedKeys = rsh.handle(rs);

try (ResultSet rs = stmt.getGeneratedKeys()) {
generatedKeys = rsh.handle(rs);
}
} catch (final SQLException e) {
this.rethrow(e, sql, (Object[])params);
} finally {
Expand Down

0 comments on commit d563207

Please sign in to comment.