Reputation: 425
I have defined a datasource in my baseContext.xml
<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource" lazy-init="default" autowire="default" autowire-candidate="default">
<property name="driverClassName" value="oracle.jdbc.OracleDriver"></property>
<property name="url" value=""></property>
<property name="username" value=""></property>
<property name="password" value=""></property>
<property name="testWhileIdle" value=""></property>
<property name="testOnBorrow" value="tue"></property>
<property name="validationQuery" value=""></property>
</bean>
This datasource is writing a clob value to a oracle db. And while doing so it throws this error
org.springframework.dao.InvalidDataAccessApiUsageException: OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], not on [org.apache.commons.dbcp.PoolableConnection]:specify a corresponding NativeJdbcExtractor; nested exception is java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection cannot be cast to oracle.jdbc.OracleConnection
I tried to set this property "accessToUnderlyingConnectionAllowed" as true but it said cannot instantiate the bean, property does not exist.
Other solutions like this asked to use native jdbc extractor but i dont know how to specify that in this bean
I am using Spring Batch running on tomcat and i just specify this datasource when i configure the JobRepository
<batch:job-repository data-source="datasource" id="jobrepo" transaction-manager="transacMnager" table-prefix="" isolation-level-for-create="READ_COMMITTED"></batch:job-repository>
How can i solve this issue?
Upvotes: 0
Views: 2207
Reputation: 6944
You can set the lobHandler in the jobRepository FOr example:
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transacMnager" />
<property name="isolationLevelForCreate" value="READ_COMMITTED" />
<property name="lobHandler">
<bean class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor">
<bean class="yourCorrectJdbcExtractor" />
</property>
</bean>
</property>
</bean>
I hope it can be useful
Angelo
Upvotes: 1