aspose file tools*
The moose likes JDBC and the fly likes oracle thin driver scrollable resultset.absolute(1) is not returing the first row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "oracle thin driver scrollable resultset.absolute(1) is not returing the first row" Watch "oracle thin driver scrollable resultset.absolute(1) is not returing the first row" New topic
Author

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

Helen Ge
Ranch Hand

Joined: May 24, 2005
Posts: 68
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


SCJP,SCWCD,SCDJWS,SCBCD
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Helen Ge
Ranch Hand

Joined: May 24, 2005
Posts: 68
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: oracle thin driver scrollable resultset.absolute(1) is not returing the first row
 
Similar Threads
resultset question
updateable and scrollable resultset for oracle driver
help with recordset
Scrollable ResultSet
Problem with Result Set pointer.