Announcement Announcement Module
Collapse
No announcement yet.
Not able to connect to oracle datasource using spring batch framework Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Not able to connect to oracle datasource using spring batch framework

    I am new to spring batch framework.I have downloaded the spring batch framework with the samples project.I am able to run the samples application succesfully using the spring default hsql database in eclipse.Since we need to connect to oracle database I have created a sample batch job which gets the data from the oracle database table and outputs it to text file.

    Below are the details:

    1) SampleBatchJob.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-2.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

    <bean parent="stepScope" />
    <bean parent="jobConfigurationRegistryBeanPostProcessor" />

    <bean id="sampleBatchJob" class="org.springframework.batch.core.configuratio n.JobConfiguration">
    <property name="restartable" value="true" />
    <property name="startLimit" value="100" />
    <property name="steps">
    <list>
    <bean id="job"
    class="org.springframework.batch.execution.step.Si mpleStepConfiguration">
    <property name="commitInterval" value="100" />
    <property name="startLimit" value="100" />
    <property name="saveRestartData" value="true" />
    <property name="tasklet">
    <bean
    class="org.springframework.batch.execution.tasklet .RestartableItemProviderTasklet">
    <property name="itemProvider">
    <bean
    class="org.springframework.batch.item.provider.Inp utSourceItemProvider">
    <property name="inputSource"
    ref="jobInputSource" />
    </bean>
    </property>
    <property name="itemProcessor">
    <bean
    class="org.springframework.batch.sample.item.proce ssor.JobProcessor">
    <property name="writer">
    <bean class="org.springframework.batch.sample.dao.FlatFi leJobWriter">
    <property name="outputSource" ref="flatFileOutputSource" />
    </bean>
    </property>
    </bean>
    </property>
    </bean>
    </property>
    </bean>
    </list>
    </property>
    </bean>

    <bean id="jobInputSource"
    class="org.springframework.batch.io.cursor.JdbcCur sorInputSource">
    <property name="dataSource" ref="ATSDataSource" />
    <property name="mapper">
    <bean
    class="org.springframework.batch.sample.mapping.Jo bInputMapper" />
    </property>
    <property name="sql">
    <value>
    SELECT ats_batch_schedule.ats_batch_schedule_id,ats_batch _schedule.version
    from ats_batch_schedule
    </value>
    </property>
    </bean>
    <bean id="flatFileOutputSource" class="org.springframework.batch.io.file.support.F latFileItemWriter">
    <property name="resource">
    <bean class="org.springframework.core.io.FileSystemResou rce">
    <constructor-arg type="java.lang.String" value="target/test-outputs/SampleBatchJobOutput.txt" />
    </bean>
    </property>
    </bean>
    <aop:config>
    <aop:aspect id="moduleLogging" ref="itemProcessorLogAdvice">

    <aop:after
    pointcut="execution( * org.springframework.batch.item.ItemProcessor+.proc ess(Object)) and args(item)"
    method="doStronglyTypedLogging" />

    </aop:aspect>
    </aop:config>
    </beans>

    I have added this line to batch.properties file:

    batch.jdbc.atsdriver=oracle.jdbc.driver.OracleDriv er
    batch.jdbc.atsurl=jdbc:oracle:thin:@ACN6WT3K81.acc enture.com:1521:XE
    batch.jdbc.atsuser=system
    batch.jdbc.atspassword=password

    and I have added this data-source-context.xml:

    <bean id="ATSDataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="${batch.jdbc.atsdriver}" />
    <property name="url" value="${batch.jdbc.atsurl}" />
    <property name="username" value="${batch.jdbc.atsuser}" />
    <property name="password" value="${batch.jdbc.atspassword}" />
    </bean>

    ANd I am getting the following error:

    org.springframework.jdbc.UncategorizedSQLException : Executing query; uncategorized SQLException for SQL [
    SELECT ats_batch_schedule.ats_batch_schedule_id,ats_batch _schedule.version
    from ats_batch_schedule
    ]; SQL state [null]; error code [17023]; Unsupported feature; nested exception is java.sql.SQLException: Unsupported feature
    at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.translate(SQLStateSQLExceptionTransl ator.java:121)
    at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.translate(SQLErrorCodeSQLExcepti onTranslator.java:322)
    at org.springframework.batch.io.cursor.JdbcCursorInpu tSource.executeQuery(JdbcCursorInputSource.java:33 3)
    at org.springframework.batch.io.cursor.JdbcCursorInpu tSource.open(JdbcCursorInputSource.java:564)
    at org.springframework.batch.io.cursor.JdbcCursorInpu tSource.read(JdbcCursorInputSource.java:203)
    at org.springframework.batch.item.provider.InputSourc eItemProvider.next(InputSourceItemProvider.java:48 )
    at org.springframework.batch.execution.tasklet.ItemPr oviderProcessTasklet.execute(ItemProviderProcessTa sklet.java:141)
    at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.doTaskletProcessing(SimpleStepExe cutor.java:372)
    at org.springframework.batch.execution.step.simple.De faultStepExecutor.doTaskletProcessing(DefaultStepE xecutor.java:61)
    at org.springframework.batch.execution.step.simple.Si mpleStepExecutor$2.doInIteration(SimpleStepExecuto r.java:347)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:324)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:201)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:131)
    at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.processChunk(SimpleStepExecutor.j ava:334)
    at org.springframework.batch.execution.step.simple.Si mpleStepExecutor$1$2.doInTransaction(SimpleStepExe cutor.java:220)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:128)
    at org.springframework.batch.execution.step.simple.Si mpleStepExecutor$1.doInIteration(SimpleStepExecuto r.java:208)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:324)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:201)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:131)
    at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.process(SimpleStepExecutor.java:1 85)
    at org.springframework.batch.execution.job.DefaultJob Executor.run(DefaultJobExecutor.java:97)
    at org.springframework.batch.execution.launch.SimpleJ obExecutorFacade.start(SimpleJobExecutorFacade.jav a:199)
    at org.springframework.batch.execution.launch.SimpleJ obLauncher.runInternal(SimpleJobLauncher.java:248)
    at org.springframework.batch.execution.launch.SimpleJ obLauncher$1.run(SimpleJobLauncher.java:292)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
    at org.springframework.batch.execution.launch.SimpleJ obLauncher.run(SimpleJobLauncher.java:280)
    at org.springframework.batch.sample.AbstractBatchLaun cherTests.testLaunchJob(AbstractBatchLauncherTests .java:82)
    at org.springframework.batch.sample.AbstractValidatin gBatchLauncherTests.testLaunchJob(AbstractValidati ngBatchLauncherTests.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:154 )
    at junit.framework.TestCase.runBare(TestCase.java:127 )
    at org.springframework.test.ConditionalTestCase.runBa re(ConditionalTestCase.java:76)
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit 3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
    Caused by: java.sql.SQLException: Unsupported feature
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:269)
    at oracle.jdbc.dbaccess.DBError.throwUnsupportedFeatu reSqlException(DBError.java:690)
    at oracle.jdbc.driver.OracleConnection.createStatemen t(OracleConnection.java:3260)
    at org.springframework.batch.io.cursor.JdbcCursorInpu tSource.executeQuery(JdbcCursorInputSource.java:32 4)
    ... 45 more

    Please let me know what I need to do to fix this issue.

    Thanks,
    Aruna
    Last edited by arunaalluri; Jan 8th, 2008, 09:09 PM.

  • #2
    Aruna,

    This looks like an issue with your database and what it will support. The JdbcCursorInputSource opens a cursor over a set of data. From the error you supplied, the opening of that cursor is causing the exception. If I had to take a guess, I would say it looks like your database driver is Jdbc 2.0, but not 3.0 compliant. Jdbc 3.0 introduced holding cursors open across commits, which is what allows the JdbcCursorInputSource to keep a cursor over the whole dataset, while still committing periodically.

    Also, on a sidenote, please put all code/xml configuration/exceptions inside of tags, so that they can be read more easily.

    -Lucas

    Comment


    • #3
      resolved that error

      Thanks a lot for the solution.

      That helped me a lot

      Comment

      Working...
      X