This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

Does CallableStatement have to be closed?

 
Jian Yi
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Report post to moderator
I need to modify the following code in a way that the upper level will handle the SQLException. The original code is:

I understand that I need to move the catch block to the upper level and declare the methods with throws SQLExeption. My question is, if SQLException is thrown at the line of "val = cstmt.executeUpdate();" then it got thrown to upper level. So the cstmt never gets closed (that's what finally block is doing). I wonder if it is ok for cstmt without being closed. What could happen? Or, is it possible that when CallableStatment::executeUpdate() throws a SQLException, it closes the statement for us automatically?
Thanks a lot,
Jenny
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please reply to this post
 
    Bookmark Topic Watch Topic
  • New Topic