Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to implement createShared() method of CachedRowSet?

 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I need to create a copy of the existing cachedrowset object for pagination.
I have a link which on click will display a page with 16 records and at the bottom there will next,prev button for pagination.
So on 1st click of the link I am:
1. passing the pageNo as 0
2. fetching all the records from the db as Resultset Object.
3. passing pageNo as 1 and populating 16 records from the resultset.

Now when i will click the next button i am passing the pageNo as 1,but i am going to the same method where i have populated the CRS object with RS object.
I have the intention of fetching next set of records which is there in CRS object,but again the RS query is executed,which i dont want.
I want all my records shud be populated in the CRS object from the RS object only once.
Each time i am clicking the next or prev button i wll iterate the CachedRowSet and display in jsp.
I tried CreateShared() ..buts its not working.

Please Suggest....



Thanks
Amarshi
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Did you populate the CachedRowSet following this principle:


That should populate your cache. When you navigate the cache, there is no need to go to the database.

disclaimer found on the same page:
However, a CachedRowSet object does have a limitation: It is limited in size by the amount of data it can store in memory at one time.



i am going to the same method where i have populated the CRS object with RS object.
I have the intention of fetching next set of records which is there in CRS object,but again the RS query is executed,which i dont want.
Put a check in your code, so that it does not have to redo the query and CachedRowSet population if it has already been done.


When you try to build a pagination mechanism, it is good to look at what the ranch has to offer you, in it's FAQs and Journal.
 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Cumps wrote:Hi,

Did you populate the CachedRowSet following this principle:


That should populate your cache. When you navigate the cache, there is no need to go to the database.

disclaimer found on the same page:
However, a CachedRowSet object does have a limitation: It is limited in size by the amount of data it can store in memory at one time.



i am going to the same method where i have populated the CRS object with RS object.
I have the intention of fetching next set of records which is there in CRS object,but again the RS query is executed,which i dont want.
Put a check in your code, so that it does not have to redo the query and CachedRowSet population if it has already been done.


When you try to build a pagination mechanism, it is good to look at what the ranch has to offer you, in it's FAQs and Journal.





Hi jan,
I am using like below:

crs.populate(rs,crs1.getPageSize()* pageNum);

This works for the page-0 when i go for next page ,this wil work but again the query has to be executed.
even if i wll make use of creteCopy() method of CRS then it wll add only those records which are present in the original CSR object.


Thanks
Amarshi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic