Invoking Stored Procedure using Spring JdbcBatchItemWriter

倖福魔咒の 提交于 2020-01-06 12:53:09

问题


I would like to execute a Stored Procedure using spring JdbcBatchItemWriter. My current code looks like :

<bean id="xyzWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
......
<property name="sql" value="update abc where x=:paramX" />
......
</bean>

I would like to replace this update sql query with a Stored Proc call. I would like to handle it in the xml file itself. Any help is really appreciated.

Thanks


回答1:


Did you tried running SP through JdbcBatchItemWriter? because I also had same requirement and i just tried and it worked for me

<bean id="trackItemWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
        <property name="dataSource" ref="mySQLDatasource"/>
        <property name="itemPreparedStatementSetter">
            <bean class="com.MyDataPreparedStatmentSetter"/>
        </property>
        <property name="assertUpdates" value="false" />
        <property name="sql" value="Call my_Stored_Proc (?,?,?,?)"/>
    </bean>

Hope it helps.



来源:https://stackoverflow.com/questions/9066407/invoking-stored-procedure-using-spring-jdbcbatchitemwriter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!