commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql QueryTag.java
Date Mon, 30 Sep 2002 17:30:28 GMT
jstrachan    2002/09/30 10:30:28

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/sql
                        QueryTag.java
  Log:
  Patched code to match comments made by Kevin Jones and Steve Downey that the result set
should always be closed before the statement.
  
  I think that now (finally) the closing and exception handling of the SQL tags is working
correctly. Though I stand corrected if anyone can find another bug here! :-)
  
  Revision  Changes    Path
  1.13      +11 -11    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- QueryTag.java	27 Sep 2002 09:44:40 -0000	1.12
  +++ QueryTag.java	30 Sep 2002 17:30:28 -0000	1.13
  @@ -220,25 +220,17 @@
               
               // lets nullify before we close in case we get exceptions
               // while closing, we don't want to try to close again
  -            Statement tempStatement = statement;
  -            statement = null;
  -            tempStatement.close();
               ResultSet tempRs = rs;
               rs = null;
               tempRs.close();
  +            Statement tempStatement = statement;
  +            statement = null;
  +            tempStatement.close();
           }
           catch (SQLException e) {
               throw new JellyException(sqlStatement + ": " + e.getMessage(), e);
           }
           finally {
  -            if (statement != null) {
  -                try {
  -                    statement.close();
  -                }
  -                catch (SQLException e) {
  -                    log.error("Caught exception while closing statement: " + e, e);
  -                }
  -            }
               if (rs != null) {
                   try {
                       rs.close();
  @@ -246,6 +238,14 @@
                   catch (SQLException e) {
                       log.error("Caught exception while closing result set: " + e, e);
                   } 
  +            }
  +            if (statement != null) {
  +                try {
  +                    statement.close();
  +                }
  +                catch (SQLException e) {
  +                    log.error("Caught exception while closing statement: " + e, e);
  +                }
               }
               if (conn != null && !isPartOfTransaction) {
                   try {
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message