Results 1 to 5 of 5

Thread: Required: Example code for JdbcPagingItemReader

  1. #1
    Join Date
    Mar 2011
    Posts
    15

    Question Required: Example code for JdbcPagingItemReader

    Hi,

    Can somebody please post an example of how to use JdbcPagingItemReader? The documentation only lists an XML snippet without the consumer code that uses it.

    Regards,
    Shantanu

  2. #2

    Default

    Check out the XML configuration on this post


    http://forum.springsource.org/showth...edSQLException

  3. #3
    Join Date
    Mar 2011
    Posts
    15

    Default

    Quote Originally Posted by vbforums View Post
    Check out the XML configuration on this post


    http://forum.springsource.org/showth...edSQLException
    Thanks, but I am not looking for the XML configuration. I need the Java code that uses JdbcPagingItemReader.

    Regards,
    Shantanu

  4. #4

    Default

    You shouldn't normally use it in java code. You should tie it in XML that that sends it to a processor and then a writer.

    IF you did want to use it in java code.. here you go:

    Code:
    private JdbcPagingItemReader<Person> personReader
    
    public void setPersonReader( JdbcPagingItemReader<Person> personReader) {
      this.personReader = personReader;
    }
    
    public void myMethod() {
      Person p = personReader.read();
      while ( p != null) {
         System.out.println(p);
         p = personReader.read();
       }
    }

  5. #5
    Join Date
    Mar 2011
    Posts
    15

    Default

    Bwawok,

    Thanks for the tip. I think I have not understood fully how is this feature intended to be used. I want to use this in non-batch environments -- e.g. can I use this for pagination of data records on web pages? How can I jump to a certain page (can I load a page on-demand)?

    In the code example in the post above, it seems the rows are supposed to be read sequentially! What if I want to switch back and forth between pages?

    Regards,
    Shantanu

Tags for this Thread

Posting Permissions

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