• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Helen Ge
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36031
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!