This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have an application where I have to list 30 records per JSP page. There can be any number of records in the database. Which of the methods is faster and consumes less resources? -use session object to store all the records and the display them on the pages (30 at a time) -go to the database for each page and get all records and display 30 per page Any reply will be appreciated. Thanks
Hi, It is usually a compromise between a "faster" RESPONSE and "lesser" storage (read memory). You will not be able to have both of them at the same time. Going to your question, it is better to go for Method 2) which reads the records off the database for every page since you do not know about the number of records in the database. This carries an overhead of a database access for every page access. But, you can work with limited memory (30 records) Or you could read more than 30 records (say 5 * 30) and store them in the session object. Thus, you will be able to show 5 pages without a db access. Again, that number depends on your application and it's needs. Hope this helps. Ashwin.
This is a topic which has been discussed here many times, so it may well be worth a few searches on past messages. You should find some quite detailed discussions and code samples both here and in the JDBC forum.
Originally posted by Frank Carver: This is a topic which has been discussed here many times, so it may well be worth a few searches on past messages. You should find some quite detailed discussions and code samples both here and in the JDBC forum.