You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dg...@apache.org on 2004/06/06 16:35:39 UTC
cvs commit: jakarta-commons/dbutils/src/java/org/apache/commons/dbutils QueryRunner.java
dgraham 2004/06/06 07:35:39
Modified: dbutils/src/java/org/apache/commons/dbutils QueryRunner.java
Log:
Added protected close() methods so subclasses can provide specialized
error handling.
PR: 29393
Revision Changes Path
1.11 +38 -7 jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java
Index: QueryRunner.java
===================================================================
RCS file: /home/cvs/jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- QueryRunner.java 15 Mar 2004 05:31:40 -0000 1.10
+++ QueryRunner.java 6 Jun 2004 14:35:39 -0000 1.11
@@ -20,6 +20,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.sql.Types;
import java.util.Arrays;
@@ -86,7 +87,7 @@
} catch (SQLException e) {
this.rethrow(e, sql, params);
} finally {
- DbUtils.close(stmt);
+ close(stmt);
}
return rows;
@@ -111,7 +112,7 @@
try {
return this.batch(conn, sql, params);
} finally {
- DbUtils.close(conn);
+ close(conn);
}
}
@@ -222,9 +223,9 @@
} finally {
try {
- DbUtils.close(rs);
+ close(rs);
} finally {
- DbUtils.close(stmt);
+ close(stmt);
}
}
@@ -290,7 +291,7 @@
return this.query(conn, sql, params, rsh);
} finally {
- DbUtils.close(conn);
+ close(conn);
}
}
@@ -410,7 +411,7 @@
this.rethrow(e, sql, params);
} finally {
- DbUtils.close(stmt);
+ close(stmt);
}
return rows;
@@ -465,7 +466,7 @@
try {
return this.update(conn, sql, params);
} finally {
- DbUtils.close(conn);
+ close(conn);
}
}
@@ -492,6 +493,36 @@
*/
protected ResultSet wrap(ResultSet rs) {
return rs;
+ }
+
+ /**
+ * Close a <code>Connection</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ * @since DbUtils 1.1
+ */
+ protected void close(Connection conn) throws SQLException {
+ DbUtils.close(conn);
+ }
+
+ /**
+ * Close a <code>Statement</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ * @since DbUtils 1.1
+ */
+ protected void close(Statement stmt) throws SQLException {
+ DbUtils.close(stmt);
+ }
+
+ /**
+ * Close a <code>ResultSet</code>. This implementation avoids closing if
+ * null and does <strong>not</strong> suppress any exceptions. Subclasses
+ * can override to provide special handling like logging.
+ * @since DbUtils 1.1
+ */
+ protected void close(ResultSet rs) throws SQLException {
+ DbUtils.close(rs);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org