• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet doubt

 
Lalit mishra
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the following thread:

Closing JDBC Resources

Kaydell
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic