Sep 11th, 2012, 06:50 AM
Spring Batch and Informix
It seems like Informix is not supported by Spring Batch (at least it's not in the list of supported platforms). The documentation says:
"If you are using a database platform that is not in the list of supported platforms, you may be able to use one of the supported types, if the SQL variant is close enough. To do this you can use the raw JobRepositoryFactoryBean instead of the namespace shortcut and use it to set the database type to the closest match. The major differences between platforms are mainly accounted for by the strategy for incrementing primary keys, so often it might be necessary to override the incrementerFactory as well (using one of the standard implementations from the Spring Framework)."
I defined a Job Repository implemented by JobRepositoryFactoryBean and set the "databaseType" propety to "oracle". It seems to work fine. At least I can run my jobs and see the database tables populated with data.
Is this the correct way? Can I use "oracle" database type this way? Should I have implemented/overrided something to connect to Informix properly?
I'm also trying to run Spring Batch Admin just to access this meta data repository but something is going wrong. As the database type is not supported I have tried to override the default datasource and jobrepository beans creating 2 files (data-source-context.xml and execution-context.xml) in "\spring-batch-admin-sample\src\main\resources\META-INF\spring\batch\override" directory with these contents:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.informix.jdbc.IfxDriver" />
<property name="url" value="jdbc:informix-sqli://entelserver:9091/batch:informixserver=ol_entelserver" />
<property name="username" value="user" />
<property name="password" value="pass" />
<bean id="jobRepository" class="org.springframework.batch.core.repository.s upport.JobRepositoryFactoryBean">
<property name="databaseType" value="oracle"/>
<property name="dataSource" ref="dataSource"/>
<property name="transactionManager" ref="transactionManager"/>
but when I try to run the application I get this error "DatabaseType not found for product name: [Informix Dynamic Server]". So it seems like I'm not overriding beans correctly.
Any idea how to configure a not supported DBMS so that Spring Batch Admin can connect?
Sep 21st, 2012, 10:09 AM
I'd say that this is what you need to do if you don't want to deep dive into the integration of a new database in Spring Batch.
If you don't specify the database type explicitly, Spring Batch tries to figure it out from the datasource metadata (hence the error message). The framework will then choose appropriate implementations (e.g. sequence generation for the execution metadata, in its own tables) depending on the database type. It will connect to the database correctly as long as it doesn't hit a barrier when trying to choose these strategies.
If Spring Batch handles Informix just like it does with Oracle, good for you :-)
Note Spring Batch uses the same detection mechanism for some of its components (e.g. queryProvider property in JdbcPagingItemReader), so you could need to set up the correct implementation yourself in such cases, instead or relying on the framework.
Oct 1st, 2012, 04:06 AM
Thanks for the answer. I know this could be a temporary solution before it fails. Is there any article/post where I can read about how to integration of a new database in Spring Batch?
Oct 1st, 2012, 04:24 AM
I don't know if such a resource exists on the web. If you stick to the core of Spring Batch (no component like JdbcPagingItemReader) and it's working (execution metadata are correctly updated), you're pretty much done.
You can also fork the project and update/implement the appropriate classes/interface, like DataFieldMaxValueIncrementer and DataFieldMaxValueIncrementerFactory.
Tags for this Thread