Results 1 to 5 of 5
  1. #1
    deepakd is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default SQL files execute : Incorrect syntax near 'go'.

    Hi ,


    Getting below issue when trying to run the ant script.

    I am trying to run few sql files from the folder through ant script in which I configured the "jtds-1.2.5.jar".
    Unable to run the GO statment in the sql file. But able to execute same file it through sql studio with out any error.

    ************************************************** **
    <target name="runscript">
    <sql driver="net.sourceforge.jtds.jdbc.Driver"
    url="jdbc:jtds:sqlserver://${xxxxx}:${1433}/;"
    userid="${aaaaaaaa}" password="${bbbbbb}"
    classpathref="jtds-1.2.5.jar">
    <path>
    <fileset file="${basedir}\source\Mydata.sql"/>
    </path>
    </sql>
    </target>


    ************************************************** **
    ERROR:
    ************************************************** **
    java.sql.SQLException: Incorrect syntax near 'go'.
    at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnos tic(SQLDiagnostic.java:368)
    at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(Td sCore.java:2820)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCor e.java:2258)
    at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(T dsCore.java:632)
    at net.sourceforge.jtds.jdbc.JtdsStatement.processRes ults(JtdsStatement.java:584)
    at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL (JtdsStatement.java:546)
    at net.sourceforge.jtds.jdbc.JtdsStatement.executeImp l(JtdsStatement.java:723)
    at net.sourceforge.jtds.jdbc.JtdsStatement.execute(Jt dsStatement.java:1160)
    at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLE xec.java:775)
    at org.apache.tools.ant.taskdefs.SQLExec.runStatement s(SQLExec.java:751)
    at org.apache.tools.ant.taskdefs.SQLExec$Transaction. runTransaction(SQLExec.java:1055)
    at org.apache.tools.ant.taskdefs.SQLExec$Transaction. access$000(SQLExec.java:985)
    at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLE xec.java:653)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: SQL files execute : Incorrect syntax near 'go'.

    The file should contain a series of SQL statements, each ending with a semi-colon.
    GO is not a SQL statement.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    deepakd is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Re: SQL files execute : Incorrect syntax near 'go'.

    I used sqlcmd to execute the 'go' statement from ant script.

    do JTDS support SQL server 2008 R2 ?
    Now i am geting a new issue :
    JTDC driver.
    SQL server 2008 R2

    java.sql.SQLException: Invalid object name 'dbo.xxName'.
    at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnos tic(SQLDiagnostic.java:368)
    at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(Td sCore.java:2820)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCor e.java:2258)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: SQL files execute : Incorrect syntax near 'go'.

    What does your script look like?
    Because, as I said, 'GO' is not valid SQL syntax.
    It's part of T-SQL, which is not going to run through JDBC.

    JTDS does support 2008.

    That new error is pretty self explanatory.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    ravijaan is offline Member
    Join Date
    May 2014
    Posts
    1
    Rep Power
    0

    Default Re: SQL files execute : Incorrect syntax near 'go'.

    Try using a delimiter in your ant target. Something like

    <target name="runscript">
    <sql driver="net.sourceforge.jtds.jdbc.Driver"
    url="jdbc:jtds:sqlserver://${xxxxx}:${1433}/;"
    userid="${aaaaaaaa}" password="${bbbbbb}"
    classpathref="jtds-1.2.5.jar"
    delimiter="GO">


    Courtesy:newschuyl: Do not pass GO

Similar Threads

  1. Incorrect information?
    By santa in forum New To Java
    Replies: 8
    Last Post: 02-27-2012, 02:35 AM
  2. Incorrect formulas
    By kprofgold in forum New To Java
    Replies: 46
    Last Post: 01-31-2012, 04:27 PM
  3. Incorrect numbering of log files using log4j-1.2.8.jar
    By neetu.jainvi@gmail.com in forum Advanced Java
    Replies: 0
    Last Post: 12-09-2010, 09:34 AM
  4. What in my function incorrect?
    By artemff in forum New To Java
    Replies: 5
    Last Post: 01-02-2010, 05:25 PM
  5. Incorrect Package? Help!
    By chaits86 in forum NetBeans
    Replies: 10
    Last Post: 12-17-2008, 04:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •