![](/img/trans.png)
[英]spring batch: efficient way to query results of a stored procedure within a tasklet
[英]How to call a stored procedure from a Spring Batch Tasklet?
提到Spring Batch中的TaskletStep可以用來調用存儲過程。 誰能提供一個如何從 TaskletStep 調用存儲過程的示例? 到目前為止,我已經這樣做了,但它拋出了一個異常,說“配置問題:元素 [callStoredProcedure] 無法訪問”
<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 MyClass implements Tasklet{
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
JdbcTemplate myJDBC=new JdbcTemplate(getDataSource());
myJDBC.execute(sql);
return RepeatStatus.FINISHED;
}
}
應該如何以及在哪里配置存儲過程? 將不勝感激收到任何指點?
代替
value="call stored_procedure()"
就放
value="stored_procedure"
沒有 () 結束。 那應該可以解決您的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.