diff --git a/WHATSNEW b/WHATSNEW index 6d2736df9..bd604343a 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -29,6 +29,11 @@ Other changes: * supports nested text +* won't override files that are already in the correct + format. + +* now supports REM comments as well as // and -- + Fixed bugs: ----------- diff --git a/docs/manual/CoreTasks/sql.html b/docs/manual/CoreTasks/sql.html index 579bc3888..097ddefcc 100644 --- a/docs/manual/CoreTasks/sql.html +++ b/docs/manual/CoreTasks/sql.html @@ -9,7 +9,7 @@

Description

Executes a series of sql statement via JDBC to a database. Statements can either be read in from a text file using the src attribute or from between the enclosing sql tags.

-

Multiple statements can be set and each statement is delimited from the next use a semi-colon. Individual lines within the statements can be commented using either -- or // at the start of the line.

+

Multiple statements can be set and each statement is delimited from the next use a semi-colon. Individual lines within the statements can be commented using either --, // or REM at the start of the line.

The auto-commit attribute specifies whether auto commit should be turned on or off whilst executing the statements. If auto-commit is turned on each statement will be executed and committed. If it is turned off the statements will all be executed as one transaction.

diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 78d71734b..58956189e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -68,9 +68,10 @@ import java.sql.*; /** * Reads in a text file containing SQL statements seperated with semicolons * and executes it in a given db. - * Both -- and // maybe used as comments. + * Comments may be created with REM -- or //. * * @author Jeff Martin + * @author Michael McCallum */ public class SQLExec extends Task { @@ -425,8 +426,12 @@ public class SQLExec extends Task { try{ while ((line=in.readLine()) != null){ - if (line.trim().startsWith("//")) continue; - if (line.trim().startsWith("--")) continue; + line = line.trim(); + if (line.startsWith("//")) continue; + if (line.startsWith("--")) continue; + if ( line.length() > 2 ) { + if (line.substring(0,3).equalsIgnoreCase("REM")) continue; + } sql += " " + line; sql = sql.trim(); @@ -535,7 +540,7 @@ public class SQLExec extends Task { do { rs = statement.getResultSet(); if (rs != null) { - log("Processing new result set.", Project.MSG_VERBOSE); + log("Processing new result set.", Project.MSG_VERBOSE); ResultSetMetaData md = rs.getMetaData(); int columnCount = md.getColumnCount(); StringBuffer line = new StringBuffer();