How can I update a JTable with a new ResultSet?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Peter_Pahules
Posted On:   Friday, October 4, 2002 09:57 AM


I have a JFrame with three JTables. When a row is selected from the previous table, the following tables require updating with the new ResultSet. I can get the ResultSet but cannot figure out how to reload the tables with the new data.

Re: How can I update a JTable with a new ResultSet?

Posted By:   Morten_Sjoegren  
Posted On:   Friday, October 4, 2002 11:43 AM

You have extract each attribut from each post one at a time, and put them into the JTable.

You've to use a "while" or a "for" :



ResultSet rs = stmt.executeQuery(SQLString); // stmt is a Statement



while (rs.next())

{

attribut_name1 = rs.getXXX(); // Replace XXX with varible type like int or String

JTable_name.setValueAt(attribut_name1, row_number, column_number);

}



I hope you get the idea

Remember, if you have data in the JTable you have to create it from new.
About | Sitemap | Contact