Exception HandlingJavaJDBC

java.sql.SQLException: ORA-00911: invalid character

1 Mins read
java.sql.SQLException: ORA-00911: invalid character solution, java.sql.SQLException: ORA-00911: invalid character root cause,why am i getting java.sql.SQLException: ORA-00911: invalid character,JDBC error java.sql.SQLException: ORA-00911: invalid character,
java.sql.SQLException: ORA-00911: invalid character resolution, how to resolve java.sql.SQLException: ORA-00911: invalid character,

The “invalid character” exception is very common in a JDBC code due to a small mistake. I have seen many beginners asking this question and searching on google that
I am getting below exception, while running a JDBC query. I have checked my query its working fine when I run directly from a SQL client. What could be the reason?

java.sql.SQLException: ORA-00911: invalid  character
        at  oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at  oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:676)
         at  oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:602)
         at  oracle.jdbc.driver.T2CPreparedStatement.executeForDescribe(T2CPreparedStatement.java:571)
         at  oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
         at  oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
         at  oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
         at  oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)

Answer : Most of the time, If you are getting this exception while running a JDBC query from a Java program check if your query is having semicolon (“;”) at the end of it or anywhere in the query. You should not have semicolon in a JDBC query.

I have observed this with the programmers who are comfortable with Oracle or some other database (e.g. MySQL, PostgresSQL) clients where semicolon is required at the end of query (like many PL/SQL command line clients).

Hope this post helps you resolve your problem quickly, feel free share your thoughts in comments if this helps or not.


Leave a Reply

Your email address will not be published. Required fields are marked *