aspose file tools
The moose likes JDBC and the fly likes Change of statements! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 26168
    
  66

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Change of statements!