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.

Related posts

Best Java Books For Beginners in 2021

3 Mins read
Java has already been the most popular language for over three decades. 10 years ago, I did a compilation of most popular…

Java: How To Make Remote Async Calls With A Lambda Supplier

1 Mins read
It is super easy to convert any remote call into an async call from Java 8 onwards. You can use a combination…

7 Secrets to Creating and Managing Remote Teams of Java Developers

3 Mins read
Developing a software product presents a huge challenge for tech leaders and CEOs, especially for those who have decided to go with…
Power your team with InHype

Add some text to explain benefits of subscripton on your services.


Leave a Reply

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