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

JDBC interfaces should extend a Closable interface

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 6
    • core-libs
    • x86
    • windows_2000

      A DESCRIPTION OF THE REQUEST :
      Connection, ResultSet, Statement and any other suitable JDBC interfaces should extend a Closable interface.

      JUSTIFICATION :
      Boilerplate code must currently be duplicated to handle each resource separately. Justification for this is equivalent to the need for java.io.Closable to manage stream resources.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Connection c = DriverManager.getConnection(...);
      PreparedStatement ps = c.prepare(....);
      ResultSet rs = ps.executeQuery();
      // ...
      Closable c1 = c;
      Closable c2 = ps;
      Closable c3 = rs;

      c1.close();
      c2.close();
      c3.close();

      ACTUAL -
      There is currently no such interface. java.io.Closable exists, but does not throw an exception; a suitable java.sql.Closable interface would presumably need to throw a SQLException.

            lancea Lance Andersen
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: