I am unsure whether a statement and resultset should be closed after each query or after all my queries have been made (ie at the same time i close the connection)?
Correct me if I’m wrong, but I’m pretty sure both work?
However, would the database eventually crash if I didn’t close a statement after each query and then performed a lot of queries?
On the other hand, would it be inefficient and time-wasting to keep closing & creating statements for every query?
I’ve read up a lot on this problem before asking this question, but I’m still uncertain. Any help appreciated,
tre.
From http://www.precisejava.com/javaperf/j2ee/JDBC.htm#JDBC118:
In a nutshell, you don’t have to explicitly close your
ResultSetobjects, but it’s better to do so to free up memory earlier on. Failing to close yourResultSetobjects will just cause the memory that it occupies (which can be small, or large, depending on the size of the result set) to be occupied until the correspondingStatementobject is closed.