0
votes

I am new to spring batch and batch admin. I stuck in a scenario where i want to use multiple datasource. i.e. One for batch meta-data and business schema(application tables).

I am using below code in my batch-mysql.properties file.

For batch matadata tables

batch.jdbc.driver=com.mysql.jdbc.Driver
batch.jdbc.url=jdbc:mysql://localhost:3306/batch
batch.jdbc.user=root
batch.jdbc.password=root
batch.jdbc.testWhileIdle=true
batch.jdbc.validationQuery=SELECT 1
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-mysql.sql
batch.schema.script=classpath:/org/springframework/batch/core/schema-mysql.sql
batch.business.schema.script=classpath*:business-schema-mysql.sql

For application schema

db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/applicationschema
db.user=root
db.password=root

if i remove below line of code batch.business.schema.script=classpath*:business-schema-mysql.sql

then i am getting an exception that above property couldn't found. if keep as it is then it is creating application table in batch matadata schema.

1

1 Answers

0
votes

Just don't supply any value to the property batch.business.schema.script. Try to leave it like shown below :

batch.business.schema.script=

Also, if you don't want to drop and create batch meta tables every time your application is started, you should set batch.data.source.init=false in your batch properties file.

EDIT : This is how my batch-oracle.properties file looks like :

 batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer
 batch.isolationlevel=READ_COMMITTED
 batch.business.schema.script=
 batch.data.source.init=false
 batch.job.service.reaper.interval=6000
 batch.schema.script=classpath:/org/springframework/batch/core/schema-drop-oracle10g.sql
 batch.jdbc.url=jdbc:oracle:thin:@localhost:1521:mydb
 batch.table.prefix=BATCH_
 batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
 batch.verify.cursor.position=true
 batch.jdbc.validationQuery=SELECT 1 FROM dual
 batch.jdbc.password=mypassword
 batch.jdbc.testWhileIdle=false
 batch.jdbc.user=user
 batch.jdbc.pool.size=5
 batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-oracle10g.sql