aspose file tools*
The moose likes JDBC and the fly likes Closing a callable statement and connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Closing a callable statement and connection" Watch "Closing a callable statement and connection" New topic
Author

Closing a callable statement and connection

Srinivasa Kadiyala
Ranch Hand

Joined: Jun 10, 2004
Posts: 237
Callable Statement:

I have overridden close() method and in that I am closing a statement object. Can I also use it for closing the CallableSatement Object?
or
Shall I have to write another close() [over ridden] metod to use the callable statement?

Connection:

I am passing the Connection object as an argument to a methd and after using connection object in that method is it required to close the connection object?

Thanks in advance


Srini
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
Callable Statement:

I have overridden close() method and in that I am closing a statement object. Can I also use it for closing the CallableSatement Object?
or Shall I have to write another close() [over ridden] metod to use the callable statement?
If you are doing something special, then u should override the close() method else let it be executed with default implementation. As you know CallableStatement object is a subclass of Statement class, you can use the same close() method.

************************************
Connection:
I am passing the Connection object as an argument to a methd and after using connection object in that method is it required to close the connection object?
After you pass the connection object, to another method and after u have used it, i would prefer not to close the connection object in that called method.
If i don't need the connection method in the calling method after calling the another method, i would close the connection object in the calling method. This makes reading of code and debugging easy from my point of view.

Let me know if i am wrong.

Regards
Makarand Parab
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Closing a callable statement and connection
 
Similar Threads
method with SQL parameter
Setting Array of String to callable statement ?
Proper way to close Connection, Statement & ResultSet
Closing of connection object in Stateless Session Beans
Pool connection leak error