I need to display the result of a select from database like a report on web page. also I have to apply functionality such as filter and sorting.
what is the best way to do this?
do I have to reconstruct the select sql statement everytime and do retireveing from database everytime.
in MS ADO,there is filter and sort in recordset,what about in JAVA world?
It would be better to modify the SQL and let the DB server do the job for you. If you are using Hibernate, there are sort and filter methods that can be applied directly to the query object. Otherwise, I would look at the jakarta Commons CollectionUtils package for sorting the results.
what I like is get the result from database and cache the result as an object,then I can munipulate the result such as filtering and sorting.
I think it depends on, how much and how long data to be cached. If you application use small amount of data for a short period, then you can cache for filtering and sorting.
Otherwise you should do sorting and filter at database.
How can I do for small amount and short period?
why it's not apply for big?
Look at using EM Cache.
You don't want to do it on large amounts of data because you'll be eating up memory very quickly, also the sorting and filtering operations will become expensive.