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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

why semicolon not allowed in JDBC Oracle?

801904Sep 24 2012 — edited Nov 20 2014
hello everyone

consider this:

ResultSet rset = stmt.executeQuery ("select count(*) from Invoices;"); // note there is a semicolon at the end of SQL statement

Question: why does having a semicolon at the end of the SQL statement in JDBC (1.6, 1.7) for Oracle 11g database generates an error such as below:

Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

Once I remove the semicolon, the code works fine.

I always thought that ending all SQL statements with a semicolon was part of SQL standard and Oracle PL/SQL certaintly supports and encourages semicolons (and requires it in many cases).
So why does JDBC object to semicolons ?
Is there a JDBC Oracle driver setting/property that can be set to =true/=1 such that I can use semicolons at end of SQL statements ?

thanks.

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 22 2012
Added on Sep 24 2012
4 comments
3,019 views