Results 1 to 3 of 3

Thread: Exception Handling with JDBCCursorItemReader

  1. #1
    Join Date
    Sep 2011
    Posts
    2

    Default 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. #2
    Join Date
    May 2011
    Location
    New Delhi, India
    Posts
    157

    Default

    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. #3
    Join Date
    Sep 2011
    Posts
    2

    Default

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

    thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •