Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 71413 invoked from network); 18 Aug 2005 21:23:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2005 21:23:20 -0000 Received: (qmail 87369 invoked by uid 500); 18 Aug 2005 21:23:17 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 87320 invoked by uid 500); 18 Aug 2005 21:23:17 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 87306 invoked by uid 99); 18 Aug 2005 21:23:17 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2005 14:23:17 -0700 Received: by ajax.apache.org (Postfix, from userid 99) id 4CAC5E3; Thu, 18 Aug 2005 23:23:16 +0200 (CEST) From: bugzilla@apache.org To: dev@ant.apache.org Subject: DO NOT REPLY [Bug 36265] New: - sql task: Create table fails on DB2 X-Bugzilla-Reason: AssignedTo Message-Id: <20050818212316.4CAC5E3@ajax.apache.org> Date: Thu, 18 Aug 2005 23:23:16 +0200 (CEST) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=36265 Summary: sql task: Create table fails on DB2 Product: Ant Version: 1.6.5 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Core tasks AssignedTo: dev@ant.apache.org ReportedBy: sb48109@yahoo.com This happens with DB2 version 8.1, and the 8.1 db2jdbc drivers (from IBM I believe). When executing a file with simple sql create table commands, I got: CreateTables: [echo] Creating tables for user **** in jdbc:db2://database:50000/user:deferPrepares=false; driver=com.ibm.db2.jcc.DB2Driver [sql] Executing file: creates.sql [sql] Failed to execute: CREATE TABLE ACCRUAL_RULE ( ACCRUAL_RULE VARCHAR( 80) ) BUILD FAILED build.xml:2963: com.ibm.db2.jcc.b.SQLException: A result has opened by the previous getResultSet() or getUpdateCount() call, Need to call getMoreResults() Here is the stack trace of the exception: at com.ibm.db2.jcc.b.ce.getResultSet(ce.java:491) at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLExec.java:501) at org.apache.tools.ant.taskdefs.SQLExec.runStatements(SQLExec.java:470) at org.apache.tools.ant.taskdefs.SQLExec$Transaction.runTransaction(SQLExec.java:664) It appears that the implementation of the sql task does not follow closely the jdbc spec; according to http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#execute(java.lang.String), execute() returns whether a ResultSet is available (and getMoreResults() is similar). Therefore one should not call getResultSet() when execute() or hasMoreResult() has returned false. Similarly, calling getUpdateCount() when execute() or getMoreResults() returned true does not make sense. With the modification below, which I believe follows these rules, the problem went away. In SQLExec, I replaced: ====== BEGIN EXISTING CODE ret = statement.execute(sql); updateCount = statement.getUpdateCount(); resultSet = statement.getResultSet(); do { if (!ret) { if (updateCount != -1) { updateCountTotal += updateCount; } } else { if (print) { printResults(resultSet, out); } } ret = statement.getMoreResults(); if (ret) { updateCount = statement.getUpdateCount(); resultSet = statement.getResultSet(); } } while (ret); ==================== BEGIN REPLACEMENT CODE boolean ret; int updateCount = 0, updateCountTotal = 0; ret = statement.execute(sql); do { if (!ret) { updateCount = statement.getUpdateCount(); if (updateCount != -1) { updateCountTotal += updateCount; } } else { resultSet = statement.getResultSet(); if (print) { printResults(resultSet, out); } } ret = statement.getMoreResults(); } while (ret); ==================== END REPLACEMENT CODE -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org