bodewig     2005/04/11 02:31:16

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
                        SQLExec.java
  Log:
  merge fix for 27162
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.214 +4 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.213
  retrieving revision 1.503.2.214
  diff -u -r1.503.2.213 -r1.503.2.214
  --- WHATSNEW  4 Apr 2005 07:42:28 -0000       1.503.2.213
  +++ WHATSNEW  11 Apr 2005 09:31:15 -0000      1.503.2.214
  @@ -12,6 +12,10 @@
   Fixed bugs:
   -----------
   
  +* SQL task would try access result sets of statements that didn't
  +  return any, causing problems with Informix IDS 9.2 and IBM DB2 8.1
  +  FixPak 6 (or later). Bugzilla Reports 27162 and 29954.
  +
   Changes from Ant 1.6.2 to Ant 1.6.3beta1
   ========================================
   
  
  
  
  No                   revision
  No                   revision
  1.62.2.5  +34 -8     ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  
  Index: SQLExec.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v
  retrieving revision 1.62.2.4
  retrieving revision 1.62.2.5
  diff -u -r1.62.2.4 -r1.62.2.5
  --- SQLExec.java      9 Mar 2004 17:01:34 -0000       1.62.2.4
  +++ SQLExec.java      11 Apr 2005 09:31:15 -0000      1.62.2.5
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2000-2004 The Apache Software Foundation
  + * Copyright  2000-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -66,7 +66,6 @@
    * The possible values are: <b>continue</b> execution, only show the error;
    * <b>stop</b> execution and commit transaction;
    * and <b>abort</b> execution and transaction and fail task.</p>
  -
    *
    * @since Ant 1.2
    *
  @@ -489,13 +488,13 @@
               return;
           }
   
  +        ResultSet resultSet = null;
           try {
               totalSql++;
               log("SQL: " + sql, Project.MSG_VERBOSE);
   
               boolean ret;
               int updateCount = 0, updateCountTotal = 0;
  -            ResultSet resultSet = null;
   
               ret = statement.execute(sql);
               updateCount = statement.getUpdateCount();
  @@ -507,12 +506,14 @@
                       }
                   } else {
                       if (print) {
  -                        printResults(out);
  +                        printResults(resultSet, out);
                       }
                   }
                   ret = statement.getMoreResults();
  -                updateCount = statement.getUpdateCount();
  -                resultSet = statement.getResultSet();
  +                if (ret) {
  +                    updateCount = statement.getUpdateCount();
  +                    resultSet = statement.getResultSet();
  +                }
               } while (ret);
   
               log(updateCountTotal + " rows affected",
  @@ -537,15 +538,40 @@
                   throw e;
               }
               log(e.toString(), Project.MSG_ERR);
  +        } finally {
  +            if (resultSet != null) {
  +                resultSet.close();
  +            }
           }
       }
   
       /**
  -     * print any results in the statement.
  +     * print any results in the statement
  +     * @deprecated use [EMAIL PROTECTED] #printResults(java.sql.ResultSet, 
java.io.PrintStream)
  +     *             the two arg version} instead.
  +     * @param out the place to print results
  +     * @throws SQLException on SQL problems.
        */
  -    protected void printResults(PrintStream out) throws 
java.sql.SQLException {
  +    protected void printResults(PrintStream out) throws SQLException {
           ResultSet rs = null;
           rs = statement.getResultSet();
  +        try {
  +            printResults(rs, out);
  +        } finally {
  +            if (rs != null) {
  +                rs.close();
  +            }
  +        }
  +    }
  +
  +    /**
  +     * print any results in the result set.
  +     * @param rs the resultset to print information about
  +     * @param out the place to print results
  +     * @throws SQLException on SQL problems.
  +     * @since Ant 1.6.3
  +     */
  +    protected void printResults(ResultSet rs, PrintStream out) throws 
SQLException {
           if (rs != null) {
               log("Processing new result set.", Project.MSG_VERBOSE);
               ResultSetMetaData md = rs.getMetaData();
  
  
  

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

Reply via email to