• Post Reply Bookmark Topic Watch Topic
  • New Topic

To load a huge records from a DB to a JTable

 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a DB with 10000 rows and 20 columns.
I want to publish all these records in a JTable. What will be the best and the most efficient approach to do this.
Is it possible to load the data or records dynamically as the scrollpane moves.



 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought of using a 2D array but I did not find it very efficient approach.

Suggest some efficient approach.
 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
buntha Choudhary wrote:I thought of using a 2D array but I did not find it very efficient approach.

Suggest some efficient approach.


instead of 2d array you can use vector.
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Bharat , but I don't find that is a very efficient approach as the DB may have more than 20000 records.
And even I want to know , is there any dynamic way of loading the content in the JTable on the basis of ScrollPane movement.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the API docs for JList It has an example of a dynamic list. You can adapt it for JTable
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manish .
I need to load all the records from DB atleast once , so is vector the best approach to go ahead ? or any other better approach.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Load the records as and when required and cache them locally.
Vector is synchronized. Considering its a Swing client, I doubt you need that. I personally would prefer an ArrayList
 
Bharath Raja
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
buntha Choudhary wrote:
I need to load all the records from DB atleast once , so is vector the best approach to go ahead ? or any other better approach.

hope
this will help you
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I will try the caching technique.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!