I have a datasource that connects to an Oracle database in my application. Is it possible to access to another schema that includes the Spring-batch metadata tables through
Because spring.batch.table-prefix=
did not work for me and I could not immediately configure the second datasource, I took a look at the actual table generation done by Spring Batch.
The sql-Script which generates the tables is static (at least in the release 4.2.2 and for Postgresql).
Therefore it is no wonder that spring.batch.table-prefix
does not work. At least in my case as the tables do not yet exist in the database.
To fix it I copied schema-postgresql.sql
to my resource folder and modified it to my needs (creating the schema and referencing it explicitly).
CREATE SCHEMA SPRING_BATCH;
CREATE TABLE SPRING_BATCH.BATCH_JOB_INSTANCE (
JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY ,
-- and so on
In my application.properties
I added:
spring.batch.initialize-schema=always
spring.batch.table-prefix=SPRING_BATCH.BATCH_
spring.batch.schema=classpath:db/create_spring_batch_tables.sql