JDK-5105637 : Closeable interface for classes in java.sql package
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.sql
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-09-22
  • Updated: 2010-07-08
  • Resolved: 2006-03-01
Name: jl125535			Date: 09/22/2004

Finally the classes in java.io have implemented a Closeable interface, so you can write one close method that takes a Closeable argument. I have waiting for this feature to be added for a long time, and it made me glad when I saw that the interface was added to JDK 1.5. But to my disappointment the interface wasn't also added to the java.sql package.

In short. Let the interfaces

extend a Closeable interface.

The close method in the Closeable interface in the java.io package declares that it throws an IOException, so it can't be used. You could either make IOException and SQLException extend/implement a common base, and alter the Closeable interface so it declares that the close method throws that common base, or duplicate the interface, and place it in java.sql package as well. I guess there are other ways to solve it as well.

As it is now we have to write close methods that are overloaded with different arguments.

I would like to be able to write one close method that can close statements, result sets and connections.
(Incident Review ID: 311502) 

EVALUATION One of the reasons is this requires an IOException to be thrown and JDBC requires a SQLException

EVALUATION Will not be incorporating this interface into JDBC