GeeCON Prague 2014*
The moose likes JDBC and the fly likes Suggest me a best way to do this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Suggest me a best way to do this" Watch "Suggest me a best way to do this" New topic
Author

Suggest me a best way to do this

Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hi all,
I am querying a large table with millions of record based on some condition. Say this results in a 70 thousand records. Then again this 70 thousand records are filtered based on 2 three levels of conditions and finally I get a 30 thousand records.
I want to achieve pagination and I should not hit the database again as well,Currently I do this way.
I read all the 30 thousand records and store all the records in a file. I just use file pointers and manipulate things and achieve pagination to show 1000 records per page. Whenever the user request for the next page, I go to the file read it and display the next page and so on
But I feel this is not the efficent way to do this as I get lot of errors while I do paginations because of the file pointers.
Can somebody enlight me by suggesting an efficent method to do this.

Thanks in Advance

Regards,
Sivaraman.L
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
What database do you use?

If you use MYSQL the limit clause should be something for you to look into


SCJP1.4
Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hi,
I use DB2 7.0. as the Database

Reagrds,
Sivaraman.L
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Sorry! DB2 does not have a limit clause. Maybe there is a workaround like in MSSQL

with mysql you only select the rows that you limit

Sorry that I couldn't help you
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

db2 has:
FETCH FIRST X ROWS ONLY
which works like the limit clause.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
GeeCON Prague 2014
 
subject: Suggest me a best way to do this