jstrachan 2002/09/26 11:35:23
Modified: jelly/src/java/org/apache/commons/jelly/tags/sql
QueryTag.java
Log:
Patch for bug scarab#12888
Revision Changes Path
1.10 +18 -2
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java
Index: QueryTag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- QueryTag.java 1 Jun 2002 10:21:14 -0000 1.9
+++ QueryTag.java 26 Sep 2002 18:35:23 -0000 1.10
@@ -168,6 +168,8 @@
log.debug( "About to lookup connection" );
+ ResultSet rs = null;
+ Statement statement = null;
try {
conn = getConnection();
@@ -202,14 +204,14 @@
log.debug( "About to execute query: " + sqlStatement );
}
- ResultSet rs = null;
if ( hasParameters() ) {
PreparedStatement ps = conn.prepareStatement(sqlStatement);
setParameters(ps);
+ statement = ps;
rs = ps.executeQuery();
}
else {
- Statement statement = conn.createStatement();
+ statement = conn.createStatement();
rs = statement.executeQuery(sqlStatement);
}
@@ -220,6 +222,20 @@
throw new JellyException(sqlStatement + ": " + e.getMessage(), e);
}
finally {
+ if (statement != null) {
+ try {
+ statement.close();
+ }
+ catch (SQLException e) {
+ } // Not much we can do
+ }
+ if (rs != null) {
+ try {
+ rs.close();
+ }
+ catch (SQLException e) {
+ } // Not much we can do
+ }
if (conn != null && !isPartOfTransaction) {
try {
conn.close();
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>