Spring Batch using Sybase IQ data source

1.3k views Asked by At

How do we properly configure Sybase datasource in a Spring Batch?

Currently I am using a JdbcPagingItemReader for reading DB and creating the data source using Tomcat DBCP. However the following error occurs on the batch run.

Caused by: java.lang.IllegalArgumentException: DatabaseType not found for product name: [Sybase IQ]
at org.springframework.batch.support.DatabaseType.fromProductName(DatabaseType.java:77)
at org.springframework.batch.support.DatabaseType.fromMetaData(DatabaseType.java:108)
at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:162)
at org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer.createJobRepository(DefaultBatchConfigurer.java:82)
at org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer.initialize(DefaultBatchConfigurer.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:344)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:295)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130)
... 13 more

For reference, I am currently JConn4-7.0 jar for connectivity. There are no issues connecting to a Oracle Database though [with pool properties changed for Oracle].

Any insight would be helpful.

Please feel free to edit the question for clarity/readability.

1

There are 1 answers

2
Michael Minella On BEST ANSWER

The error you're getting is probably from not explicitly configuring the database type on your JobRepositoryFactoryBean. Without it set, we attempt to determine what type it is from the JDBC metadata. To explicitly specify Sybase as your job repository's database type, configure it via the databaseType attribute on the JobRepositoryFactoryBean like below:

<bean id="jobRepository"
    class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseType" value="SYBASE" />
</bean>

You can read more about this feature in the Spring Batch documentation here: http://docs.spring.io/spring-batch/reference/html/configureJob.html#nonStandardDatabaseTypesInRepository