0

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.

Jay
  • 429
  • 2
  • 8
  • 23
  • You might need to check this post "Why Spring's jdbcTemplate.batchUpdate() so slow?" [link] (http://stackoverflow.com/questions/20360574/why-springs-jdbctemplate-batchupdate-so-slow) – Arar Jun 21 '16 at 15:19
  • Saif thanks for the reply. That issue is regarding performance but for me it is not executing only. – Jay Jun 21 '16 at 15:32
  • Why aren't using `JdbcBatchItemWriter`? – Dean Clark Jun 21 '16 at 16:40
  • @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 suggest – Jay Jun 21 '16 at 17:44
  • What is your target Database? Can you write a single `MERGE` or `UPSERT` statement instead? – Dean Clark Jun 21 '16 at 22:38

1 Answers1

0

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.

Jay
  • 429
  • 2
  • 8
  • 23