This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes when to close resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "when to close resultset" Watch "when to close resultset" New topic
Author

when to close resultset

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 364
Hi-
I have a question re: resultsets...if a resultset obj goes out of scope, does it automatically close the rs? or is there a chance it could be left open?
We're suing IBM DB2 JDBC 2.0 drivers...
thanks,
Max Tomlinson
sandeep balyan
Ranch Hand

Joined: Jul 25, 2001
Posts: 134
It is always a good practise to close the result set as it can cause a exception some where in application.like null pointer exception .if u close statements than its okee as it does close resultset ..
try to do statement close in finally block to keep fair that even if u r program throws exception u r connection and statement is closed ..
that means resources r free
regds


Want to do something great will do one day
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"balyan",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Also, please try not to use contractions (u, r etc) since they often make it harder to understand posts.
Thanks.
Dave
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: when to close resultset
 
Similar Threads
consuquences of not closing ResultSet?
too many open cursors
Another JSP Problem - Database related
javax.sql.DataSource+JNDI+ connection ????
Closing ResultSet and Statement