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

Spring JIRA | Sven Bonacker | 6 years ago
  1. 0

    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}

    Spring JIRA | 6 years ago | Sven Bonacker
    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
  2. 0

    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}

    Spring JIRA | 6 years ago | Sven Bonacker
    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
  3. 0

    It seems the table prefix isn't applied in all places. Please confirm. Below is part of the exception I receive - please note the "EXIT_CODE" invalid identifier error is due to tables named in the default manner which are out of date. Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, TASK_COUNT = ?, TASK_STATISTICS = ?, EXIT_CODE = ? where ID = ?]; nested exception is java.sql.SQLException: ORA-00904: "EXIT_CODE": invalid identifier *SNIPPED* at org.springframework.batch.execution.repository.dao.SqlStepDao.update(SqlStepDao.java:257) at org.springframework.batch.execution.repository.SimpleJobRepository.saveOrUpdate(SimpleJobRepository.java:185) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy0.saveOrUpdate(Unknown Source) at org.springframework.batch.execution.step.simple.SimpleStepExecutor.process(SimpleStepExecutor.java:269) at org.springframework.batch.execution.job.DefaultJobExecutor.run(DefaultJobExecutor.java:76) at org.springframework.batch.execution.facade.SimpleJobExecutorFacade.start(SimpleJobExecutorFacade.java:137) at org.springframework.batch.execution.bootstrap.SimpleJobLauncher.run(SimpleJobLauncher.java:101) at org.springframework.batch.execution.bootstrap.SimpleJobLauncher.run(SimpleJobLauncher.java:118) at org.springframework.batch.execution.bootstrap.BatchCommandLineLauncher.start(BatchCommandLineLauncher.java:80) at org.springframework.batch.execution.bootstrap.BatchCommandLineLauncher.main(BatchCommandLineLauncher.java:117)

    Spring JIRA | 9 years ago | Douglas C. Kaminsky
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, TASK_COUNT = ?, TASK_STATISTICS = ?, EXIT_CODE = ? where ID = ?]; nested exception is java.sql.SQLException: ORA-00904: "EXIT_CODE": invalid identifier *SNIPPED*
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Pass Integer Array for Number column in database

    Stack Overflow | 8 months ago | Kanif Gaikwad
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT * from Tablename WHERE id= ?]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected NUMBER got schema.app_id
  6. 0

    BadSqlGrammarException running CommandLineJobRunner - Spring Forum

    spring.io | 12 months ago
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested exception is java.sql.SQLException: ORA-00942: table or view does not exist

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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()
    2. Spring Framework
      SimpleJdbcTemplate.queryForObject
      1. org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
      2. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
      3. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602)
      4. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636)
      5. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665)
      6. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673)
      7. org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:716)
      8. org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:169)
      9. org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:174)
      9 frames
    3. Spring Batch Core
      SimpleJobOperator.stop
      1. org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.getJobExecution(JdbcJobExecutionDao.java:244)
      2. org.springframework.batch.core.explore.support.SimpleJobExplorer.getJobExecution(SimpleJobExplorer.java:113)
      3. org.springframework.batch.core.launch.support.SimpleJobOperator.findExecutionById(SimpleJobOperator.java:389)
      4. org.springframework.batch.core.launch.support.SimpleJobOperator.stop(SimpleJobOperator.java:374)
      4 frames