3

It is mentioned that a TaskletStep in Spring Batch can be used to call a stored procedure. Could anyone provide an example of how to invoke a Stored Procedure from a TaskletStep? So far I have done this but it throws an exception saying "Configuration problem: The element [callStoredProcedure] is unreachable"

       <job id="job1">
          <step id="step1">
                <tasklet ref="myTasklet"/>
          </step>
       </job>

       <bean id="myTasklet" class="MyClass">
             <property name="dataSource" ref="dataSource"/>
             <property name="sql" value="call stored_procedure()"/>
       </bean>

Java Class

        class MyClass implements Tasklet{
               @Override
               public RepeatStatus execute(StepContribution contribution,
        ChunkContext chunkContext) throws Exception {
                  JdbcTemplate myJDBC=new JdbcTemplate(getDataSource());
                  myJDBC.execute(sql);
                  return RepeatStatus.FINISHED;
             }      
        }
                

How and where should the stored procedure be configured? Would be grateful to receive any pointers?

Braiam
  • 1
  • 11
  • 47
  • 78
5122014009
  • 3,766
  • 6
  • 24
  • 34
  • Possible duplicate of [Spring JDBC Template for calling Stored Procedures](https://stackoverflow.com/questions/9361538/spring-jdbc-template-for-calling-stored-procedures) – Philip Wrage May 01 '19 at 02:50

1 Answers1

0

Instead of

value="call stored_procedure()"

just put

value="stored_procedure"

without () on end. That should resolve your issue

CryptoFool
  • 21,719
  • 5
  • 26
  • 44
ojhasaurav
  • 11
  • 1