Freeing Resources¶
Every JDBC object consumes some number of resources. A ResultSet object,
for example, may contain a copy of every row returned by a query; a
Statement object may contain the text of the last command executed, and
so forth. It’s usually a good idea to free up those resources when the
application no longer needs them. The sample application releases the
resources consumed by the Result, Statement, and Connection objects by
calling each object’s close() method:
rs.close();
stmt.close();
con.close();
If you attempt to use a JDBC object after closing it, that object will throw an error.