This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes how to populate a large record set into JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to populate a large record set into JTable " Watch "how to populate a large record set into JTable " New topic
Author

how to populate a large record set into JTable

amar rapuru
Greenhorn

Joined: Nov 10, 2005
Posts: 2
I am accessing a database and trying to display them in JTable using count of 100.The resultset may well be very large (over 1,00,000 records).

The problem here is that I want to give user an illusion that He has got all the available data (for example,total number of record:5000), It means that scrollbar on the scrollpane should behave as if the JTable has got all the records(say 5000) but physically the table is holding just 100 records.

If user clicks the scrollbar down,using the index position I wish to display say 100 records to begin with, then as the user scrolls up and down the viewer further records are read from database and displayed.

Is there any solution for this.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
I think JTable is already sort of
designed to do what you want. If
you write your table model's
getValueAt() method to query the
database for each cell, it will
query just the visible cells, not
all n*5000 of them. (Unless you're
sorting the rows or something like
that.)

Now of course you probably don't
want to have to query the database
each for every single call to
getValueAt(), but I bet you can
work out some kind of caching scheme.


bitguru blog
amar rapuru
Greenhorn

Joined: Nov 10, 2005
Posts: 2
Brian Cole,

Thanks for your reply.

I want to retrive the database records according to the Scroll bar position and display in JTabel.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to populate a large record set into JTable
 
Similar Threads
JTable & JDBC
JTable(!!!)
Problem with JTable
JTable question
Streaming data to a view (JTable??)