Java Code:
private void AddUserActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/MyPOS","root","");
Statement stmt = (Statement)conn.createStatement();
String fname = fld_fname.getText();
String lname = fld_lname.getText();
String role = cmb_role.getSelectedItem().toString();
String uname = fld_username.getText();
String pass = fld_password.getText();
String add = "INSERT INTO admin (firstname, lastname, role, username, password) VALUES('"+fname+"', '"+lname+"', '"+role+"', '"+uname+"', '"+pass+"');";
stmt.executeUpdate(add);
conn.close();
JOptionPane.showMessageDialog(this,"Personnel Added","Add Personnel",JOptionPane.OK_OPTION);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR",JOptionPane.ERROR_MESSAGE);
System.out.println(e.getMessage());
}
I have this Java code for my POS System, Im wondering why is there a this in the JOptionPane.showMessageDialog(this,...,...)
Also, how do I display it on a table with the corresponding columns?