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 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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
wood burning stoves
 
subject: how to populate a JTable from database
 
Similar Threads
GUI from eclipse/WindowsBuilder not WYSIWYG
urgent:override a jrame
return three values from a while loop
GroupLayout not working in a JPanel
Problem in adding Jpanel to JFrame (Updated)