Announcement Announcement Module
No announcement yet.
Exception Handling with JDBCCursorItemReader Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception Handling with JDBCCursorItemReader

    I'm new to Spring Batch and am seeking help regarding the following.

    I have a job with a single step which has an itemReader, itemProcessor and ItemWriter.

    The itemReader simply uses the out-of-the-box JDBCCursorItemReader to extract data from a database table and pass it on to be processed and written.

    If the itemReader hits, for example, a database connection error, the batch should not only log the exception but should also associate a particular business code to this exception (ex.: when database connection exception, code= IDBJ0001E - Cannot connect to database).

    How can we do this with Spring Batch?

    Since it is out of the box, I can't insert try/catch, and I don't see the purpose of writing a in-house itemReader since the out-of-the-box version does the job....

    Please help!

    Thanks in advance!

  • #2
    You can do this in a listener. You can use a ItemReadListener. This is Called before and after an item is read and when an exception occurs while reading an item.


    • #3
      thanks for your help and advice. We're looking into making listeners work for us!

      thanks again!