0
votes

In my spring batch application i am trying to update the records in Writer using JdbcTemplate batchUpdate. But niether changes are reflecting in DB nor the job gets completed. when i check in JOB_EXECUTION in spring META-TABLES EXIT_CODE shows as UNKNOWN.

List<Object[]> objects = new ArrayList<Object[]>();
        for(Item item : items){
            Object[] objectsArray = new Object[]{item.getName(),item.getValidToDate(),item.getAccountNo(),item.getCode()};
            objects.add(objectsArray);
        }
        iagJdbcTemplate.batchUpdate(updateSql,objects);

And my update query is like this

UPDATE ACCOUNT_INFO SET ADDRESS= ?,DATE=? WHERE ACCOUNT=? AND CODE=?;

ACCOUNT table has composite primary key which is a combination of ACCOUNT & CODE.

NOTE : When i run the same with INSERT query it just works fine.

Please do let me know where i am going wrong.

1
You might need to check this post "Why Spring's jdbcTemplate.batchUpdate() so slow?" [link] (stackoverflow.com/questions/20360574/…)Saif Masadeh
Saif thanks for the reply. That issue is regarding performance but for me it is not executing only.Jay
Why aren't using JdbcBatchItemWriter?Dean Clark
@Dean I have to dynamically decide insert or update.... so I have written a custom writer..... Is it possible to dynamically decide insert or update from a value which I am getting from job context?? Please suggestJay
What is your target Database? Can you write a single MERGE or UPSERT statement instead?Dean Clark

1 Answers

0
votes

Issue is resolved. There is nothing wrong in the jdbcTemplate or in update query. It is some other environment related issue. Same configuration will work fine. No need to change the configurations. Thanks all.