Hi I have successfully linked my jTable to JDBC database. However, I am having trouble retrieving them. I want the saved data to appear when I restart the program but it is
First create the table model then use that fetch_data() function. Make sure your database connection is working. Call the function in main constructor. That's it.
DefaultTableModel dm;
dm=(DefaultTableModel) jTable1.getModel();
public void fetch_data(){
try{
String sql= "select * from tbl_name";
ResultSet rs=st.executeQuery(sql);
YourjTableName.setModel(DbUtils.resultSetToTableModel(rs));
}catch(Exception e){
System.out.println(e);
}
}