简体   繁体   中英

spring batch run sql script as a tasklet

Does spring batch support executing a sql scripts as part of a tasklet? Below are the sequence of steps that I'm planning to develop with spring batch.

For step 2 and 4 I need to run bunch of sql statements in sequence. How can I accomplish running a sql script?

  1. Read csv files and validate the contents
  2. if valid content, Execute a sql script that drop existing tables, and re-create tables, index etc
  3. Run the writer operations to insert the data into the table.
  4. Run sequence of stored procedures described in the .sql file.

While I don't believe Spring Batch specifically supports what you're asking for, you could take a look at ScriptUtils to see if it provides the behavior you're looking for.

If not, depending on the complexity of your SQL there is the option of using JdbcTemplate directly within a Tasklet and creating a series of Tasklets

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM