Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee", "root", "");
- PreparedStatement pt = connect.prepareStatement("UPDATE employee SET firstname=?, lastname=?, deptcode=?, phoneno=?, job=? where empno = " + empnoTField1.getText()) ;
- if(JOptionPane.showConfirmDialog(null, "Are you sure to update this employee?", "Confirm Update?", JOptionPane.YES_NO_OPTION) == 0){
- // pt.setString(1, empnoTField1.getText());
- pt.setString(1, fnameTField1.getText());
- pt.setString(2, lnameTField1.getText());
- pt.setString(3, deptCodeCombo1.getSelectedItem().toString());
- pt.setString(4, phoneTField1.getText());
- // pt.setString(6, hiredate1.getText());
- pt.setString(5, jobTField1.getText());
- pt.executeUpdate();
- connect.close();
- UpdateRecord.setVisible(false);
- displayTable();
- }
- }
- catch(SQLException sqe){
- System.out.println("SQl error: " + sqe.toString());
- }
- catch(ClassNotFoundException cnf){
- System.out.println("Class not found error: " + cnf.toString());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement