This discussion is archived
4 Replies Latest reply: Sep 24, 2012 4:30 PM by 801904 RSS

why semicolon not allowed in JDBC Oracle?

801904 Newbie
Currently Being Moderated
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 ?



  • Correct Answers - 10 points
  • Helpful Answers - 5 points