Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5105637

Closeable interface for classes in java.sql package

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs
    • x86
    • windows_xp

      Name: jl125535 Date: 09/22/2004


      A DESCRIPTION OF THE REQUEST :
      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
      java.sql.Statement
      java.sql.ResultSet
      java.sql.Connection

      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.


      JUSTIFICATION :
      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)
      ======================================================================

            lancea Lance Andersen
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: