You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2010/01/13 08:26:41 UTC

DO NOT REPLY [Bug 48533] New: When using task to execute a SQL script including Chinese, sometimes the script cannot be parsed correctly

https://issues.apache.org/bugzilla/show_bug.cgi?id=48533

           Summary: When using <sql> task to execute a SQL script
                    including Chinese,  sometimes the script cannot be
                    parsed correctly
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: mustangxu@gmail.com


Created an attachment (id=24833)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24833)
Testing SQL script

The error output is:

BUILD FAILED
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '???CREATE DATABASE IF NOT EXISTS chinatrial'
at line 1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.Util.getInstance(Util.java:381)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:734)
    at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLExec.java:565)
    at org.apache.tools.ant.taskdefs.SQLExec.runStatements(SQLExec.java:535)
    at
org.apache.tools.ant.taskdefs.SQLExec$Transaction.runTransaction(SQLExec.java:776)
    at
org.apache.tools.ant.taskdefs.SQLExec$Transaction.access$000(SQLExec.java:706)
    at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:449)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
    at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
    at org.apache.tools.ant.Main.runBuild(Main.java:758)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)



But in fact, there is NOTHING in front of "CREATE"

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48533] When using task to execute a SQL script including Chinese, sometimes the script cannot be parsed correctly

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48533

iJay <mu...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #3 from iJay <mu...@gmail.com> 2010-01-17 22:07:50 UTC ---
(In reply to comment #1)
> My guess is that the file's encoding doesn't match your platform's default
> encoding.
> 
> Does it work if you specify the files encoding using <sql>'s encoding attribute
> explicitly?

Sure, the SQL script file is utf8 encoded.  If I remove "encoding" attribute
from sql task, the error msg will be

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '??????CREATE DATABASE IF NOT EXISTS
chinatrial'

(6 questions marks)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48533] When using task to execute a SQL script including Chinese, sometimes the script cannot be parsed correctly

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48533

--- Comment #2 from iJay <mu...@gmail.com> 2010-01-17 22:05:35 UTC ---
Created an attachment (id=24853)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24853)
Ant build script

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48533] When using task to execute a SQL script including Chinese, sometimes the script cannot be parsed correctly

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48533

--- Comment #4 from Stefan Bodewig <bo...@apache.org> 2010-01-18 21:33:40 UTC ---
Your file contains a BOM (see http://en.wikipedia.org/wiki/Byte-order_mark )
and it doesn't get stripped by Java's InputStreamReader - see
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058

Ant doesn't try to strip the BOM itself so the workaround would be for you to
remove the BOM completely (by using an editor that doesn't insist on writing
one), sorry.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48533] When using task to execute a SQL script including Chinese, sometimes the script cannot be parsed correctly

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48533

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2010-01-17 21:16:32 UTC ---
My guess is that the file's encoding doesn't match your platform's default
encoding.

Does it work if you specify the files encoding using <sql>'s encoding attribute
explicitly?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.