org.springframework.jdbc.BadSqlGrammarException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I'm using the latest release 2.1.3 and renamed the 'BATCH_'-tables with my own prefix. Everything works fine except calling JobOperator.stop(long executionId)! It seems as if the JdbcJobExecutiontDao is buggy, cause the tablePrefix is on default in the query. The bug seems to be similar to [#BATCH-723] ... Here is the stacktrace: {noformat} Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION from BATCH_JOB_EXECUTION where JOB_EXECUTION_ID = ?]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: Tabelle oder View nicht vorhanden at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:716) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:169) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:174) at org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.getJobExecution(JdbcJobExecutionDao.java:244) at org.springframework.batch.core.explore.support.SimpleJobExplorer.getJobExecution(SimpleJobExplorer.java:113) at org.springframework.batch.core.launch.support.SimpleJobOperator.findExecutionById(SimpleJobOperator.java:389) at org.springframework.batch.core.launch.support.SimpleJobOperator.stop(SimpleJobOperator.java:374) ... {noformat}
    via by Sven Bonacker,
  • I'm using the latest release 2.1.3 and renamed the 'BATCH_'-tables with my own prefix. Everything works fine except calling JobOperator.stop(long executionId)! It seems as if the JdbcJobExecutiontDao is buggy, cause the tablePrefix is on default in the query. The bug seems to be similar to [#BATCH-723] ... Here is the stacktrace: {noformat} Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION from BATCH_JOB_EXECUTION where JOB_EXECUTION_ID = ?]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: Tabelle oder View nicht vorhanden at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:716) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:169) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:174) at org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.getJobExecution(JdbcJobExecutionDao.java:244) at org.springframework.batch.core.explore.support.SimpleJobExplorer.getJobExecution(SimpleJobExplorer.java:113) at org.springframework.batch.core.launch.support.SimpleJobOperator.findExecutionById(SimpleJobOperator.java:389) at org.springframework.batch.core.launch.support.SimpleJobOperator.stop(SimpleJobOperator.java:374) ... {noformat}
    via by Sven Bonacker,
  • How to get cursor result using Spring Jdbc?
    via by Unknown author,
  • Removed error-irrelevant translation stack frames from exception stack trace after exceptions were created by an SQLExceptionTranslator: When debugging Spring-JDBC queries, I find it distracting that the top stack frames always refer to SQLExceptionTranslator which is only called after an error occured that caused the exception. The translator only translates a "raw" exception into a richer exception. Therefore, I suggest that these stack entries are removed before the enriched exception is rethrown by the JdbcTemplate. It is a detail, but I believe the exception stack trace should not get polluted with details that merely reflect an implementation detail. This can also distract a user that tries debugging his/her application and who does not know how the exception handling is implemented in Spring. An example of how the stack trace looks like when using an invalid SQL statement within JdbcTemplate: {noformat} org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [This is not valid SQL]; nested exception is java.sql.SQLException: ORA-00900: invalid SQL statement at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714) at com.example.Main.main(Main.java:17) Caused by: java.sql.SQLException: ORA-00900: invalid SQL statement {noformat} With the patch the stack trace would look like: {noformat} org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [This is not valid SQL]; nested exception is java.sql.SQLException: ORA-00900: invalid SQL statement at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:614) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714) at com.example.Main.main(Main.java:17) Caused by: java.sql.SQLException: ORA-00900: invalid SQL statement {noformat} In this example, the exception is catched withing JdbcTemplate.execute, wrapped by an instance of SQLErrorCodeSQLExceptionTranslator and then rethrown. Since the SQLErrorCodeSQLExceptionTranslator is responsible for instantiating the wrapping exception, the exception's stack trace is pointing to the translator since Exception.fillInStackTrace is called in the exception's constructor (this is the default implementation of a Java exception.)
    via by Rafael Winterhalter,
  • Cannot use H2 in-memory database
    via GitHub by flyway
    ,
    • org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION from BATCH_JOB_EXECUTION where JOB_EXECUTION_ID = ?]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: Tabelle oder View nicht vorhanden at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:716) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:169) at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:174) at org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.getJobExecution(JdbcJobExecutionDao.java:244) at org.springframework.batch.core.explore.support.SimpleJobExplorer.getJobExecution(SimpleJobExplorer.java:113) at org.springframework.batch.core.launch.support.SimpleJobOperator.findExecutionById(SimpleJobOperator.java:389) at org.springframework.batch.core.launch.support.SimpleJobOperator.stop(SimpleJobOperator.java:374)

    Users with the same issue

    Andreas HäberAndreas Häber
    12 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,