File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes how to populate a JTable from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to populate a JTable from database" Watch "how to populate a JTable from database" New topic
Author

how to populate a JTable from database

oghenekaro EFEKODO
Ranch Hand

Joined: Oct 10, 2005
Posts: 56
Number FoodItem Quantity Price Description
**************************************************
1Rice 1 bag 5000 Carbohydrate
2Beans 1 bag 4000 Protein
3Palm Oil 1 bottle 500 Fats & Oil

i have a table like this in my database,need help in populating my list
with "FoodItem" from the database when my GUI comes up.

Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

I think that you need to call a method that notifies the jTable that the data has changed. The key-prefix is "fire" such as: fireTableRowsInserted().

If you're dealing with a large dataset, you might want to consider using a ResultSetTableModel instead of a DefaultTableModel. I think that it would be faster for large amounts of data.

Kaydell
oghenekaro EFEKODO
Ranch Hand

Joined: Oct 10, 2005
Posts: 56
all i really need is, when my application comes up,the food items display in the JList i used in my application.thanks in advance.
oghenekaro EFEKODO
Ranch Hand

Joined: Oct 10, 2005
Posts: 56
all i really need is, when my application comes up,the food items display in the JList i used in my application.thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to populate a JTable from database
 
Similar Threads
return three values from a while loop
Problem in adding Jpanel to JFrame (Updated)
urgent:override a jrame
GUI from eclipse/WindowsBuilder not WYSIWYG
GroupLayout not working in a JPanel