diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 9166e355f..707830a29 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -645,16 +645,16 @@ public class SQLExec extends JDBCTask { } } catch (IOException e) { closeQuietly(); + setErrorProperty(); if (onError.equals("abort")) { throw new BuildException(e, getLocation()); } - setErrorProperty(); } catch (SQLException e) { closeQuietly(); + setErrorProperty(); if (onError.equals("abort")) { throw new BuildException(e, getLocation()); } - setErrorProperty(); } finally { try { if (getStatement() != null) { @@ -788,13 +788,13 @@ public class SQLExec extends JDBCTask { goodSql++; } catch (SQLException e) { log("Failed to execute: " + sql, Project.MSG_ERR); + setErrorProperty(); if (!onError.equals("abort")) { log(e.toString(), Project.MSG_ERR); } if (!onError.equals("continue")) { throw e; } - setErrorProperty(); } finally { if (resultSet != null) { try { @@ -1093,12 +1093,12 @@ public class SQLExec extends JDBCTask { warning = warning.getNextWarning(); } } - if (treatWarningsAsErrors && initialWarning != null) { - throw initialWarning; - } if (initialWarning != null) { setWarningProperty(); } + if (treatWarningsAsErrors && initialWarning != null) { + throw initialWarning; + } } protected final void setErrorProperty() {