This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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
 
author & internet detective
Marshal
Posts: 37714
579
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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!