This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to populate a JTable from database

 
oghenekaro EFEKODO
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic