I am attempting to create a Spring Batch application. We use a SQL Anywhere database, which is effectively SQLSERVER
, a known database type. To make things easier I am using @SpringBootApplication
on my main class and @EnableBatchProcessing
on my configuration class.
The problem is that my database driver, sybase.jdbc4.sqlanywhere.IDriver
, returns a product name "SQL Anywhere" and this is not recognized by Spring, causing various errors. I was able to get past some of them by explicitly creating a JobRepositoryFactoryBean in my configuration class:
/**
* We can't rely on Spring Boot as it can't set the database type properly.
*
* By explicitly requiring the arguments in the constructor, we force the Autowiring
* to occur.
*/
@Bean
public JobRepositoryFactoryBean jobRepositoryFactory(DataSource ds, PlatformTransactionManager tm) {
JobRepositoryFactoryBean jf = new JobRepositoryFactoryBean();
jf.setDataSource(ds);
jf.setTransactionManager(tm);
jf.setDatabaseType("SQLSERVER");
jf.setTablePrefix("DBA.BATCH_");
jf.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE"); // only one instance at a time
return jf;
}
However, DefaultBatchConfigurer
fails in the intialize function, because it explicitly constructs its own JobExplorerFactoryBean.
I wonder if there is some simple way around this, or if I will have to duplicate the work in the DefaultBatchConfigurer
class and define all the beans myself and remove the @EnableBatchProcessing
annotation.