Hi guys kindly tell me how to show data from database in to table?
and how to delete row from data base and table
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Jul 18, 2016, 2:54 AM
Hima BinduPosted Jul 18, 2016, 2:15 AM
Follow these 3 steps
Load the data from the database
String sql="SELECT * FROM table";
ResultSet rs = st.executeQuery(sql);
Add each row of data to the table model...
while(rs.next())
{
String d = rs.getString("col1");
String e = rs.getString("col2");
String f = rs.getString("col3");
model.addRow(new Object[]{d, e, f});
}
Apply the model to your JTable
table.setModel(model);