Results 1 to 10 of 10
  1. #1
    vidyashree is offline Member
    Join Date
    May 2014
    Posts
    5
    Rep Power
    0

    Default java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant script

    I have an ant script which is calling a .sql file. The script is as follows:

    <project name="RemoteDeployment">
    <taskdef resource="net/sf/antcontrib/antcontrib.properties" >
    <classpath>
    <pathelement location="/oracle/ant-contrib-1.0b3.jar"/>
    </classpath>
    </taskdef>


    <target name="run_database_script" description="Run all the ddls and dmls">

    <echo message="Executing SQL script"/>

    <path id="antclasspath">
    <fileset dir="/Ora11g/product/11.2.0/client_1/jdbc/lib">
    <include name="ojdbc14.jar"/>
    </fileset>
    </path>

    <sql
    driver="oracle.jdbc.driver.OracleDriver"
    url="databaseurl"
    delimiter=";"
    userid="dbusername"
    password="dbpass"
    onerror="continue"
    autocommit="true"
    print="yes"
    classpathref="antclasspath">
    <path>
    <fileset dir="/Oracle/Database/Full">
    <include name="MasterScript.sql"/>
    </fileset>
    </path>
    </sql>

    </target>

    </project>

    Inside the MasterScript.sql I have a statement as follows:



    @/Oracle/Database/Full/DML/DML.sql



    When i try to run the ant command (`ant -f build_common.xml run_database_script -v > /Oracle/Database/Full/output_dml.log`)

    I am getting the following error

    Failed to execute: @/Oracle/Database/Full/DML/DML.sql
    [sql] java.sql.SQLException: ORA-00900: invalid SQL statement

    Note: If i run the same `MasterScript.sql` from sqlplus it is working fine. Only from the ant script is giving an error.

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

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    "@/Oracle/Database/Full/DML/DML.sql"
    Thst is a SQL Plus command.
    JDBC does not understand those.

    Why don't you just request it executes this file directly?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    vidyashree is offline Member
    Join Date
    May 2014
    Posts
    5
    Rep Power
    0

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    Quote Originally Posted by Tolls View Post
    "@/Oracle/Database/Full/DML/DML.sql"
    Thst is a SQL Plus command.
    JDBC does not understand those.

    Why don't you just request it executes this file directly?
    I have a automated build script from where I should call this MasterScript.sql
    Whenever the build takes place this MasterScript.sql should be executed automatically. Thats why I can't execute it directly..

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

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    What I mean is, the file that you are actually trying to execute, which is the DML.sql one.
    Just execute that directly.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

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

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    Actually here I have mentioned only one statement in MasterScript .sql but in real scenario there are hundreds of statements(I mean hundreds of files like DML.sql) and I need to execute them in a particular order. So I need to call them through MasterScript .sql only...
    Hope you got my point...

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

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    Quick Google for running SQL*Plus scripts through Ant and I get:
    Incanto which has a sqlplus ant task.
    Or this StackOverflow thread, which simply calls sql*plus as an exec.

    My gut says "Incanto", but that could be the leftover chicken.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    vidyashree is offline Member
    Join Date
    May 2014
    Posts
    5
    Rep Power
    0

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    Quote Originally Posted by Tolls View Post
    Quick Google for running SQL*Plus scripts through Ant and I get:
    Incanto which has a sqlplus ant task.
    Or this StackOverflow thread, which simply calls sql*plus as an exec.

    My gut says "Incanto", but that could be the leftover chicken.
    None of them are working...

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

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    What does "not working" mean?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    vidyashree is offline Member
    Join Date
    May 2014
    Posts
    5
    Rep Power
    0

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    Quote Originally Posted by Tolls View Post
    What does "not working" mean?
    I tried both Incanto and "exec" task with "sqlplus" but I m getting the same error

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

    Default Re: java.sql.SQLException: ORA-00900: invalid SQL statement while running from Ant sc

    Can you show the setup you used for each of those?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. java.sql.SQLException: Invalid column name
    By agangaia in forum JDBC
    Replies: 7
    Last Post: 04-14-2011, 01:06 PM
  2. Replies: 1
    Last Post: 04-05-2010, 01:32 AM
  3. java.sql.SQLException: ORA-01722: invalid number
    By balushanmukha in forum JDBC
    Replies: 0
    Last Post: 08-27-2008, 06:52 PM

Tags for this Thread

Posting Permissions

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