• Post Reply Bookmark Topic Watch Topic
  • New Topic

CachedRowSet.absolute(-1) returns 0  RSS feed

 
Ranch Hand
Posts: 57
1
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
the following test code:


The table customer contains four entries. The program returns:
first: 1
absolute 1: 1
last: 4
absolute -1: 0


Reading the api of absolute:
For example, calling the method absolute(-1) positions the cursor on the last row; (...)
Note: Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last().


Is there anything wrong with my program? I'd would expect absolute(-1) to return 4 instead of zero.

Regards, Bernhard
 
Ranch Hand
Posts: 924
9
IBM DB2 Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that CachedRowSet acts as a wrapper for ResulSet and in your case ResultSet is not scrollable, or is not completely fetched when you run crs.execute () method. Have a look at section 7 of relative javadoc. What happens if you try to call populate () method ? Moreover, what if you use specific CachedRowSet for Oracle jdbc driver?
 
Bernhard Goetz
Ranch Hand
Posts: 57
1
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling populate does not change the output. absolute(-1) still returns 0. Also setting the ResultSet's type for the statement to ResultSet.TYPE_SCROLL_SENSITIVE does not change the ouput.


If I create an OracleCachedRowSet explicitly it works:


Thanks for the help!
Bernhard
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!