wood burning stoves 2.0*
The moose likes JDBC and the fly likes ResultSet doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet doubt" Watch "ResultSet doubt" New topic
Author

ResultSet doubt

Lalit mishra
Ranch Hand

Joined: Sep 01, 2005
Posts: 99
Hi,
If we have a Resultset/Statement open and
if we doesnt closed the Resultset/Statement.
Rather we make ResultSet/Statement null.
will the ResultSet/Statement will be closed ?
Will there be any performance bottleneck on my Database
Thanks,
Lalit M.
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Lalit,

If you set them to null, they won't be closed.

About performance: a few years ago I worked on a project with a DB2 database, and after 250 unclosed Resultsets the webapplication just could not get anymore data from the database (the application seemed to "hang").

In short: close the connections, statements and resultsets.
(do it in a finally block, so they will always get closed, even when an exception occurs).

Herman
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

See the following thread:

Closing JDBC Resources

Kaydell
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I got tired of writing try-catch blocks around close calls and made this utility method:

It will close anything with a close() method. There is a closeable interface in the most recent JDKs so you could close some things without this reflection stuff. Note that null objects and objects that don't have close() methods all wind up in the catch.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet doubt