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.
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.