File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes closing connection and statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "closing connection and statement" Watch "closing connection and statement" New topic

closing connection and statement

eswar kumar
Ranch Hand

Joined: Oct 20, 2002
Posts: 98
what will happen if i closed a connection without closing a statement?will it affect next time when i am retriving data from data base ?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Closing a connection will close the statement, since the statement depends on it. It's good practice to explicitly close the statement though.

So much trouble in the world -- Bob Marley
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
It is expecially good practice when using connection pooling (calling connection.close() doesn't really close the connection). You can't be sure that the connection pool implementer is keeping track of your statements and closing them for you.
I agree. Here's the link:
subject: closing connection and statement
It's not a secret anymore!