• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

oracle thin driver scrollable resultset.absolute(1) is not returing the first row

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am doing pagging with oracle scrollable resultset.

I have a query "select * from (complex subquery here) where rownum<=20" and I am using the oracle thin driver scrollable resultset and point to rs.absolute(1) to expect getting the 20 records. However the first record is always missing(only the 2nd-20th rows returned). If I changed the rs.absolute(1) to rs.beforeFirst(), then all the 20 records returned.


Can someone point to me what my problem could be? Why the absolute(1) not working correctly?

Thanks
 
author & internet detective
Posts: 42165
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Helen,
After you call rs.absolute(1), are you calling rs.getXXX() before rs.next()? If so, it is going to the next row before retrieving the data from the first row.
 
Helen Ge
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne.

You are right. I overlooked the while(rs.next()) actually already moved cursor forward one position.

Now I changed to use do{....}while(rs.next()). and it works.

Thank you very much for the sharp eyes!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic