I have a spring batch application. The database that is used to store meta-data of spring batch job is configured like the following:
In application-context.xml:
<!-- stored job-meta in database - H2 -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSourceMetaData" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="h2" />
</bean>
In database.xml:
<!-- configure H2 database connection -->
<bean id="dataSourceMetaData"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:~/metaDataProd" />
</bean>
Now the application can run in the same environment in multiple instance for ex: one instance for prod & one instance for test. So I have to make the value="jdbc:h2:~/metaDataProd
configurable so that both instance does not access the same db.
I can easily do that if I generate the value from a config file. But I am wondering if there is any automatic way of doing this. For example: When an application instance is initiated then a datevalue is appended programmatic ally like this value="jdbc:h2:~/metaData2Jul
value="jdbc:h2:~/metaData4Jul