Browse Source

Restore old method signature (BWC) and plug a ResultSet leak at the same time

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277019 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
42d9dddc08
1 changed files with 24 additions and 1 deletions
  1. +24
    -1
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java

+ 24
- 1
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -509,13 +509,13 @@ public class SQLExec extends JDBCTask {
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();
@@ -559,6 +559,28 @@ public class SQLExec extends JDBCTask {
throw e;
}
log(e.toString(), Project.MSG_ERR);
} finally {
if (resultSet != null) {
resultSet.close();
}
}
}

/**
* print any results in the statement
* @deprecated use {@link #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 SQLException {
ResultSet rs = null;
rs = statement.getResultSet();
try {
printResults(rs, out);
} finally {
if (rs != null) {
rs.close();
}
}
}

@@ -567,6 +589,7 @@ public class SQLExec extends JDBCTask {
* @param rs the resultset to print information about
* @param out the place to print results
* @throws SQLException on SQL problems.
* @since Ant 1.7
*/
protected void printResults(ResultSet rs, PrintStream out) throws SQLException {
if (rs != null) {


Loading…
Cancel
Save