Does closing a java.sql.Connection also close all the statements, prepared statements, etc. obtained from that connection? Or is there going to be memory leak if I close the connection but leave the statements, etc. unclosed?
Does closing a java.sql.Connection also close all the statements, prepared statements, etc. obtained from
Share
You should not depend on it.
The spec reads as follows:
The best practice is to close ALL ResultSets, Statements, and Connections in a finally block, each enclosed in their own try/catch, in reverse order of acquisition.
Write a class like this:
Call like this: