dgraham     2004/01/31 16:16:35

  Modified:    dbutils/src/java/org/apache/commons/dbutils QueryRunner.java
  Log:
  Improved error handling in query() method.  It was possible for the 
  Statement to not get closed if the ResultSet threw an SQLException 
  during its close.  So, close Statement in finally block to ensure it gets
  called.
  
  Revision  Changes    Path
  1.8       +10 -6     
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- QueryRunner.java  11 Jan 2004 22:30:38 -0000      1.7
  +++ QueryRunner.java  1 Feb 2004 00:16:35 -0000       1.8
  @@ -208,8 +208,11 @@
               this.rethrow(e, sql, params);
   
           } finally {
  -            DbUtils.close(rs);
  -            DbUtils.close(stmt);
  +            try {
  +                DbUtils.close(rs);
  +            } finally {
  +                DbUtils.close(stmt);
  +            }
           }
   
           return result;
  @@ -430,7 +433,8 @@
       /**
        * Executes the given INSERT, UPDATE, or DELETE SQL statement.  The 
        * <code>Connection</code> is retrieved from the <code>DataSource</code> 
  -     * set in the constructor.
  +     * set in the constructor.  This <code>Connection</code> must be in 
  +     * auto-commit mode or the update will not be saved. 
        * 
        * @param sql The SQL statement to execute.
        * @param params Initializes the PreparedStatement's IN (i.e. '?') 
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to