Freeing resources

Every JDBC object consumes resources. A ResultSet object, for example, might contain a copy of every row returned by a query. A Statement object might contain the text of the last command executed. 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 returns an error.