How to get first 40 records from table , where i am using resultset in java and is that possible to get first 40 and next 40 and etc, where i am not using paggination.
3 に答える
I think it's not a good idea to extract some records from result set from performance perspective as it will load entire table data everytime. It will be good if you fire the pagination queries to load only required data (syntax is dependent on database e.g MySql provides Limit
clause).
Not sure what exactly your question is. But if I understand you correctly, you need to get only 40 records from the DB at a time, and fetch batches of 40 records each, as and when needed.
If above is true, then you can use CachedRowSet. In this, you can set the size of the batch using setPageSize().
If this is not what you want, please add more explanation to your question.
I think You are looking for pagination and every page contains 40 data item.
Query would be like -
select *
from
( select rownum rnm, a.*
from (your_query) a
where rownum <= :M )
where rnm >= :N;