'No Exception when Spring batch tables are not created

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



Solution 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:

Solution 2:[2]

Check your Spring Boot starter class or configuration class and make sure you are not excluding this auto configuration:

(exclude={BatchAutoConfiguration.class})

Also make sure this property is not set to never:

spring.batch.initialize-schema 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Jeremy Caney