Author: bodewig
Date: Fri Jul 11 03:31:17 2008
New Revision: 675909
URL: http://svn.apache.org/viewvc?rev=675909&view=rev
Log:
fix resultset und update count logic in sql. PRs 32168 and 36265.
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=675909&r1=675908&r2=675909&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jul 11 03:31:17 2008
@@ -89,6 +89,18 @@
have full control.
Bugzilla Report 34638.
+ * <sql> would fail if the executed statment didn't return a result
+ set with some JDBC driver that dissalow Statement.getResultSet to
+ be called in such a situation.
+ Bugzilla report 36265
+
+ * if the executed statement in <sql> returned a result set and an
+ update count, the count would be lost.
+
+ * if an executed statement in <sql> mixes update count and result set
+ parts, some result sets wouldn't get printed.
+ Bugzilla Report 32168.
+
Other changes:
--------------
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=675909&r1=675908&r2=675909&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java Fri Jul
11 03:31:17 2008
@@ -571,21 +571,19 @@
ret = getStatement().execute(sql);
updateCount = getStatement().getUpdateCount();
- resultSet = getStatement().getResultSet();
do {
- if (!ret) {
- if (updateCount != -1) {
- updateCountTotal += updateCount;
- }
- } else if (print) {
- printResults(resultSet, out);
+ if (updateCount != -1) {
+ updateCountTotal += updateCount;
}
- ret = getStatement().getMoreResults();
if (ret) {
- updateCount = getStatement().getUpdateCount();
resultSet = getStatement().getResultSet();
+ if (print) {
+ printResults(resultSet, out);
+ }
}
- } while (ret);
+ ret = getStatement().getMoreResults();
+ updateCount = getStatement().getUpdateCount();
+ } while (ret || updateCount != -1);
log(updateCountTotal + " rows affected", Project.MSG_VERBOSE);