Just for your information: if you use
try-with-resources (since
Java 7), the resources will be (automatically) closed in reverse order of the order in which they are created. So using this example, the
ResultSet will be closed first, followed by the
Statement and finally the
Connection
If you have a look at
the API documentation of the
close() method of the
Statement interface, you'll notice this (important) note:
Java Platform, Standard Edition 8 API Specification - Statement wrote:Note: When a Statement object is closed, its current ResultSet object, if one exists, is also closed.
Hope it helps!
Kind regards,
Roel