Follow by Email

Monday, October 17, 2016

org.springframework.jdbc.BadSqlGrammarException CallableStatementCallback; bad SQL grammar

I was getting below exception in my code where my query in the function was perfectly working fine in oracle but in java code giving me this error

org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call schema.package.function(?, ?, ?)}]; nested exception is java.sql.SQLException: Invalid column name

Thanks to this thread

I noticed there  was no ORA error message in the exception , which means the call was executed successfully in JDBC level , and than I had to check my mapper defined for this execution there I was trying to get  a column from resultset which was not selected in the original query hence the problem " java.sql.SQLException: Invalid column name"

I added the missing column in my query and got rid of this exception. Good Lesson Learned.

Lesson Learned : If there is no ORA error in your exception chances are that the JDBC call was ok and now something wrong in your java code .

No comments:

Post a Comment