Announcement Announcement Module
Collapse
No announcement yet.
Required: Example code for JdbcPagingItemReader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Check out the XML configuration on this post


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

    Comment


    • #3
      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

      Comment


      • #4
        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();
           }
        }

        Comment


        • #5
          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

          Comment

          Working...
          X