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
  • 22,531
  • 20
  • 68
  • 106

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
  • 100,966
  • 191
  • 140
  • 197
Durandal
  • 19,919
  • 4
  • 36
  • 70