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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Change of statements!" Watch "Change of statements!" New topic
Author

Change of statements!

manjit singh thakurratan
Greenhorn

Joined: Dec 23, 2009
Posts: 10
Hi

The sequence for closing connections in a jdbc driven program is

ResultSet.close
Statement.close
Connection.close

What might be the consequences if I close the connection first!? ??

Thnx
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

Manjit,
Welcome to JavaRanch!

If you close the connection first, the statement and result set are invalid. They may or may not get closed depending on your driver. They may or may not throw an exception when you try to close them; also depending on your driver. I advise you not to code that way as the results can be unpredictable.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change of statements!
 
Similar Threads
Result set not showing the latest data
PreparedStatement closes prematurely while in Websphere 5.0
Tomcat server only services 10 web service calls?
Need urgent help
throwing an Exception after first exceution ..