Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem running/batching "multiple select queries"

546130Nov 15 2006 — edited Dec 6 2006
Hi,
I have a Java application configured using Spring framework that reads multiple (disparate) SQL statements/queries from a text file and executes these ONCE on a Database server. I am using java.sql.Statement.execute() method to run these queries on the server.
This method works perfectly fine on Sybase where I have been able to code much complex queries and execute these all simultaneously on the server. However with an Oracle database I am now facing a problem. I am using an Oracle thin jdbc driver and try to execute something like (e.g.)
"select sysdate from dual;
select sysdate from dual;"

The exception thrown is
**************************************************************************************
An exception has occurred - java.lang.RuntimeException: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select sysdate from dual;
select sysdate from dual;]; nested exception is java.sql.SQLException: ORA-00911: invalid character
**************************************************************************************

I understand the semicolon (;) might be causing the problem because for Sybase such multiple statements need not be separated using semicolons but for an Oracle server this distinction is required or else it throws SQL not terminated correctly error.

I have searched on many forums and other threads @ OTN to look for a solution but found no joy. I have very limited knowledge of Oracle and hence would be really grateful if anyone could help me out here. I wonder if this is a problem with the driver, SQL itself or executing in such a fashion is not allowed at all
...Vinit
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2007
Added on Nov 15 2006
7 comments
2,288 views