Browse Source

Add an encoding attribute so SQL statements can be double byte

PR:	3080


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269719 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
2b0ab1d4d0
2 changed files with 22 additions and 1 deletions
  1. +5
    -0
      docs/manual/CoreTasks/sql.html
  2. +17
    -1
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java

+ 5
- 0
docs/manual/CoreTasks/sql.html View File

@@ -58,6 +58,11 @@ and <b>abort</b> execution and transaction and fail task.</p>
<td width="78%" valign="top">File containing SQL statements</td>
<td width="10%" valign="top">Yes, unless statements enclosed within tags</td>
</tr>
<tr>
<td valign="top">encoding</td>
<td valign="top">The encoding of the files containing SQL statements</td>
<td align="center">No - defaults to default JVM encoding</td>
</tr>
<tr>
<td width="12%" valign="top">delimiter</td>
<td width="78%" valign="top">String that separates SQL statements</td>


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

@@ -183,6 +183,11 @@ public class SQLExec extends Task {
* Action to perform if an error is found
**/
private String onError = "abort";
/**
* Encoding to use when reading SQL statements from a file
*/
private String encoding = null;

/**
* Set the classpath for loading the driver.
@@ -263,6 +268,16 @@ public class SQLExec extends Task {
public void setUserid(String userId) {
this.userId = userId;
}

/**
* Set the file encoding to use on the sql files read in
*
* @param encoding the encoding to use on the files
*/
public void setEncoding(String encoding) {
this.encoding = encoding;
}
/**
* Set the password for the DB connection.
@@ -684,7 +699,8 @@ public class SQLExec extends Task {
if (tSrcFile != null) {
log("Executing file: " + tSrcFile.getAbsolutePath(),
Project.MSG_INFO);
FileReader reader = new FileReader(tSrcFile);
Reader reader = (encoding == null) ? new FileReader(tSrcFile)
: new InputStreamReader(new FileInputStream(tSrcFile), encoding);
runStatements(reader, out);
reader.close();
}


Loading…
Cancel
Save