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


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

JDBC 679077967588385850

Post a Comment Default Comments

  1. Thanks , a very usefull hint

    ReplyDelete
  2. Thanks , a very usefull hint

    ReplyDelete
  3. David Oyarzún (Chile)July 7, 2009 at 12:10 PM

    Thanks!! it has been very usefull for me.

    ReplyDelete
  4. Superb. Thank you. A very very useful hint.

    ReplyDelete
  5. very useful hint, thank you very much

    ReplyDelete
  6. Thank u so much.This help me lot

    ReplyDelete
  7. vanitha sengottaiyanMarch 31, 2010 at 2:53 AM

    Thank u very much. u solve my problem

    ReplyDelete
  8. Thank u so much, this was very useful to me.

    ReplyDelete
  9. Thank you so much!

    BR,
    Rodolfo

    http://dotdebug.blogspot.com/

    ReplyDelete
  10. Absolutely useful and right to the point ! Thanks alot...

    ReplyDelete
  11. Thanks a lot. It saved my time.

    ReplyDelete
  12. wonderful. Saved a lot of time.

    ReplyDelete
  13. Thanks really nice one.

    ReplyDelete
  14. Thnk u for this really thnks a lot.

    ReplyDelete
  15. Thanks!!!! u solve my problem!

    ReplyDelete
  16. Very useful hint..saved my lot of time..

    ReplyDelete
  17. Wasted a lot time , finally found this thanks a lot :)

    ReplyDelete
  18. Gud info ,thnx a lot.

    ReplyDelete
  19. Thank you. It helped!

    ReplyDelete
  20. thanks, it solve my problem

    ReplyDelete
  21. Thanks, it was very useful.

    ReplyDelete
  22. That solved my issue quickly, very helpful tip

    ReplyDelete
  23. this was a life saver. Stupid JDBC! Thanks.

    ReplyDelete
  24. Thank you very much.

    ReplyDelete
  25. Thanks a lot... You are absolutely correct.

    ReplyDelete
  26. I can believe it... after three weeks to fight with this, you solved it!! THANK YOUUU

    ReplyDelete
  27. Thanks a lot, its very helpful.

    ReplyDelete
  28. that's really a good hint,you solved my problem..:)

    ReplyDelete
  29. yes "invalid Character" went off after removing the ";", But now i am getting the error "Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist", Here is the query that i am using inside my iBatis mapping file


    INSERT INTO ${schema}.DUMMY(TXN_ID, BTCH_NUM, TXN_TYPE_CD)
    VALUES (#{transactionId}, #{batchNum}, #{tnx_type_cd})


    please help me to resolve this error :(

    ReplyDelete
  30. Thanks,Its wrkng..:)

    ReplyDelete
  31. Thank u so much.This help me lot

    ReplyDelete
  32. Thank you ..
    This solved my problem .

    Abdullah

    ReplyDelete
  33. Thank you !!!
    Solved my problem

    ReplyDelete

Individuals who comment on FromDev at regular basis, will be rewarded in Top Commenter section. (Comments are selectively moderated so please do not spam)

emo-but-icon

item