File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Does CallableStatement have to be closed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Reply locked New topic

Does CallableStatement have to be closed?

Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
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,
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9058
Please reply to this post

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: Does CallableStatement have to be closed?
It's not a secret anymore!