This is my link class fill-up form:
private void cmd_updateActionPerformed(java.awt.event.ActionEvent evt) {
UserClass UC = new UserClass();
String password = new String(PW.getPassword());
String confirmPassword = new String(RPW.getPassword());
try {
if(!UN.getText().trim().equals("")&&!RPW.getText().trim().equals("")) {
DefaultTableModel model = (DefaultTableModel) UC.table_user.getModel();
String value1 = UN.getText();
String value2 = PW.getPassword().toString();
model.setValueAt(value1, UC.table_user.getSelectedRow(), 0);
model.setValueAt(value2, UC.table_user.getSelectedRow(), 1);
String sql="update user set Username='"+value1+"', Password='"+value2+"' where username='"+value1+"'";
pst=conn.prepareStatement(sql);
pst.executeUpdate();
if(password.equals(confirmPassword)) {
JOptionPane.showMessageDialog(this, "Successfully Saved!", "Success", JOptionPane.INFORMATION_MESSAGE);
this.setVisible(false);
}
else {
JOptionPane.showMessageDialog(this, "Please Enter The Right Password!" , "Mismatch", JOptionPane.INFORMATION_MESSAGE);
}
}else {
JOptionPane.showMessageDialog(null, "Please fill-up the blank form");
}
}catch (SQLException e) {
JOptionPane.showMessageDialog(null, e);
}
}
This my menuitem where my jTable stored:
private void cmd_updateActionPerformed(java.awt.event.ActionEvent evt) {
EditUserAccount EUA = new EditUserAccount (null, true);
EUA.setVisible(true);
Update_table();
}