No Exception when Spring batch tables are not created

自古美人都是妖i 提交于 2019-12-04 15:48:30

问题


If the BATCH_JOB_EXECUTION_CONTEXT was not created all I get is :

Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO BATCH_JOB_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, JOB_EXECUTION_ID) VALUES(?, ?, ?)]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

the error above is displayed while inserting into the table, but at the moment of the creation of the table (done automatically by spring batch )no error was displayed.

I would like to know the reason way the table was not created so I could know what is the issue (database permissions, problems of tablespace...) is it possible to log it in traces?

for information I'm using oracle database 12C and ojdbc8 version 12.2.0.1


回答1:


Spring Batch does not automatically create meta-data tables in your datasource. You need to run the tables creation script against your database manually.

However, if you use Spring Boot, those tables can be created automatically using the spring.batch.initialize-schema property. More details here: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-initialize-a-spring-batch-database

There are similar/related questions to this one, I'm adding them for reference here:

  • Spring Batch Framework - Auto create Batch Table
  • Spring Batch doesn't use custom datasource to create tables


来源:https://stackoverflow.com/questions/51880522/no-exception-when-spring-batch-tables-are-not-created

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!