• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CachedRowSet.populate(Resultset rs , int StartRow ) Issue

 
Neha k Agrawal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thank you for stopping here. I am facing some weird issue with CachedRowSet.populate(Resultset rs , int StartRow ) method. I am using OracleCachedRowSet.


Suppose the cursor is on 3rd row in the ResultSet and I want to copy the 2nd row .

CachedRowSet.setPageSize(1);
CachedRowSet.populate(rs , 2) ;

So it should actually copy the 2nd row but unfortunately , it is copying the 3rd row. Can anyone please tell me what am I doing wrong here.
 
G krishna kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://docs.oracle.com/javase/1.5.0/docs/api/javax/sql/rowset/CachedRowSet.html

10.0 Paging Data

refer here you will get the solution.


CachedRowSet.setPageSize(1);
CachedRowSet.populate(rs , 2) ;

When this code runs, crs will be populated with one row from rsHandle starting with the second row.

its working fine for me.

 
Neha k Agrawal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Krishna . But I have gone through this doc and I am setting the page size correctly. My issue is that populate method is not copying the rows from the startIndex which I am sending . If I am sending startIndex = 1 , it copies the data from row 2.

I have spent an entire day on this issue and I feel there is a bug with this method but I am surprised to see that no one has ever reported it .
 
G krishna kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post you code.
 
Neha k Agrawal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the code below. Basically I am populating the CachedRowSet from CachedRowSet Only instead of Result set. But I think that shouldn't matter.

So "rs" has all the rows from my query and I want to group all the rows with same key and copy them in a new CachedRowSet.

For ex:- In the below data, first 3 rows have same key[a1] , so I want to club them and put into a new cachedRowSet. So PageSize would be 3 and startIndex would be 1
but for a2 there is only one record so pageSize would be 1.

But my issue is , even if I set the startIndex as 1 , it is copying the data from 2nd row.


id , name , address
a1 name1 india
a1 name2 india
a1 name3 india
a2 name4 india
a2 name5 india
a3 name6 india






 
G krishna kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
boolean isNextRow = rs.next();

for checking weather the resultset object contains the record or not you can use


problem is that when checking rs.next() it is pointing towards the first record.
again in the inner loop you are doing rs.next() here it is pointing towards the second record instead of first.

regards
kumar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic