Browse Source

Add "REM" to the comment identifiers fro <sql> - even if it's non-standard

Submitted by:	Michael McCallum <michael@spinsoftware.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268906 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
b8de4702c9
3 changed files with 15 additions and 5 deletions
  1. +5
    -0
      WHATSNEW
  2. +1
    -1
      docs/manual/CoreTasks/sql.html
  3. +9
    -4
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java

+ 5
- 0
WHATSNEW View File

@@ -29,6 +29,11 @@ Other changes:

* <fail> supports nested text

* <fixcrlf> won't override files that are already in the correct
format.

* <sql> now supports REM comments as well as // and --

Fixed bugs:
-----------



+ 1
- 1
docs/manual/CoreTasks/sql.html View File

@@ -9,7 +9,7 @@
<h3>Description</h3>
<p>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.</p>

<p>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.</p>
<p>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.</p>

<p>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.</p>



+ 9
- 4
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -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 <a href="mailto:jeff@custommonkey.org">Jeff Martin</a>
* @author <A href="gholam@xtra.co.nz">Michael McCallum</A>
*/
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();


Loading…
Cancel
Save