Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change of statements!

 
manjit singh thakurratan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic