From 2b0ab1d4d074dc81257d811ec216e81d902e069e Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Wed, 19 Sep 2001 12:06:11 +0000 Subject: [PATCH] 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 --- docs/manual/CoreTasks/sql.html | 5 +++++ .../org/apache/tools/ant/taskdefs/SQLExec.java | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/manual/CoreTasks/sql.html b/docs/manual/CoreTasks/sql.html index 889ca2513..cdcb2a97c 100644 --- a/docs/manual/CoreTasks/sql.html +++ b/docs/manual/CoreTasks/sql.html @@ -58,6 +58,11 @@ and abort execution and transaction and fail task.

File containing SQL statements Yes, unless statements enclosed within tags + + encoding + The encoding of the files containing SQL statements + No - defaults to default JVM encoding + delimiter String that separates SQL statements diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index afa5d4410..f10ea718f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -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(); }