7

The following site shows using the new "AutoClosable" features with JDBC: link. This site is showing how the Statement will be automatically closed, but the result set is not in the try() section where it would be auto-closed. So, my question is, do I NOT need to close ResultSets directly in Java 7? I have always used the pattern: close resultset, close statement, close connection.

Rocky Pulley
  • 21,409
  • 19
  • 65
  • 104

1 Answers1

15

From the Javadoc of ResultSet:

A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
Durandal
  • 19,701
  • 3
  • 33
  • 65