Tasklet删除Spring批处理中的表 [英] Tasklet to delete a table in spring batch

查看:238
本文介绍了Tasklet删除Spring批处理中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在批处理作业中有执行不同操作的步骤.

I have steps in the batch job that does different things.

但是在开始所有这些步骤之前,我需要清除一个表.有没有简单的方法可以编写一个Tasklet来直接从作业xml文件中删除该表?

But before I begin all these steps, I need to clear a table. Is there any simple way to write a tasklet that will delete the table directly from the job xml file ?

我将ibatis用作ORM

I am using ibatis as ORM

推荐答案

您的意思是比任务小得多,例如喜欢这个伪代码吗?

you mean even more simple than a tasklet, e.g. like this pseudocode ?

<!-- xml bean config -->
<bean id="deleteTableTaskletStep" class="...">
   <property name="dataSource" ref="dataSource" />
   <property name="sql" value="delete from ..." />
</bean>

// java code
public class DeleteTableTasklet implements Tasklet {

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    new JdbcTemplate(this.dataSource).executeQuery(this.sql)
    return RepeatStatus.FINISHED;
}
}

这篇关于Tasklet删除Spring批处理中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆