Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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: 2618
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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!