|
-
Sounds like a job for SAX
Hi.
Sounds like a job for SAX. The DOM parser works for a whole document, hence problems when documents get too big. The SAX parser streams through large documents so you don't have the problem of parsing a massive file in one go. I'm no expert but this is what I would do assuming you expect the user to want all the data!
Assuming you don't expect people to want all the data the paging idea is probably the best. That way you can still use DOM. How you do this depends on the table(s) you are querying. Lets say you have a sequence for a primary key you could do something like:
SELECT id, data
FROM table1
WHERE id > ?
AND rownum < 20
Where ? is 0 for the "first page", or the last id used to build the previous page.
If this is not possible in your circumstances you could try a messier solution like:
First Page:
Open a cursor with all data.
Process the first 20 rows and quit.
Second Page:
Open a cursor with all data.
Read the first 20 and do nothing.
Process the second 20 rows and quit.
Etc.
Therefore the start row is always ((page - 1) * 20) + 1 or something like that.
I've made use of both of these methods in pl/sql and ASP. Never tried in Java but it shouldn't be a problem. Just make sure you don't reprocess or miss out rows at the page-change.
Because the second method may not have a fixed order like the sequence example there is a possibility of the paging being innaccurate, allowing reprocessing of rows depending on what insert, updates and deletes have happened.
I'd be interested to know if anyone else has some other methods!
Cheers
Tim...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|