I have two JFrame instances. Main frame has the code that populates the data from the DB to table and the other is the jFrame2 whereas the user adds or updates a record table from the Main Frame will automatically refresh
Here's my code for the Main Frame:
public void fillTable(){
String sql = "SELECT ID, UniqueCode, Name, Age, Gender, Cell FROM info";
try{
    pst = conn.prepareStatement(sql);
    rs = pst.executeQuery();
    jTable1.setModel(DbUtils.resultSetToTableModel(rs));
    jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    jTable1.getColumnModel().getColumn(0).setPreferredWidth(60);
    jTable1.getColumnModel().getColumn(1).setPreferredWidth(250);
    jTable1.getColumnModel().getColumn(2).setPreferredWidth(100);
    jTable1.getColumnModel().getColumn(3).setPreferredWidth(60);
    jTable1.getColumnModel().getColumn(4).setPreferredWidth(60);
    jTable1.getColumnModel().getColumn(5).setPreferredWidth(92);
}
catch (Exception e){
    JOptionPane.showMessageDialog(null, e);
}
}
And Here's my Code for frame 2
private void save(){
    try{
        if(name.getText().isEmpty() || age.getText().isEmpty() || cell.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Empty Fields Are Not Allowed", "System Message", JOptionPane.WARNING_MESSAGE);
        }
        else if(" ".equals(cmbGender.getSelectedItem())){
            JOptionPane.showMessageDialog(null, "Empty Fields Are Not Allowed", "System Message", JOptionPane.WARNING_MESSAGE);
        }
        else{
            connect = mysqlconnect.DBConnect(); 
            stmt = connect.createStatement();
            rs = stmt.executeQuery("SELECT Name FROM info WHERE Name='" + name.getText() + "'");
            if(rs.first()){
              JOptionPane.showMessageDialog(null, "Name already Exist, Duplicate info is not allowed", "System Message", JOptionPane.WARNING_MESSAGE);
            }else{
              sql = "INSERT INTO info(UniqueCode, Name, Age, Gender, Cell) values ('" + uniqueID.getText()+ "', '" + name.getText() + "', '" + age.getText() + "', " +
                    " '" + cmbGender.getSelectedItem() + "', '" + cell.getText() + "') ";
              Statement st = connect.createStatement();
              st.executeUpdate(sql);
              JOptionPane.showMessageDialog(null, "Successfully Saved", "System        Message", JOptionPane.INFORMATION_MESSAGE);
             this.dispose();
             frame.jTable1.repaint(); <====== Error comes here because i want to              refresh my table
            } 
        }
    }
    catch(Exception ex){
        System.out.println(ex);
    }
 
    