This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Which Place to write Connection.close() and preparedstatement.close()

 
Balaji Venkatesan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new in JDBC ...Which Place to write conn.close() and pstmt.close() Help Me ....

 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Best bet regarding your question is in the finally block for every method.



Closing "should" be in order. Closing say the connection DOES NOT necessarily mean (the JVM) will close the statement or result set for you.

If you are working with Java 7 then you can use the try-with-resource to shorten your code. here for more info
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic