Guest User

Untitled

a guest
Feb 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. public void actionPerformed(ActionEvent e) {
  2. if (e.getActionCommand().equalsIgnoreCase("Save")) {
  3. try {
  4. Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  5. Connection con = DriverManager.getConnection("jdbc:ucanaccess://E:\IDM Downloads\Compressed\student managemtnt system\StudentManagementSystem\student.accdb");
  6.  
  7. try {
  8. String str = "insert into student(RollNo,SName,Phno,Sex,FName,Occupation,"
  9. + "MName,Dob,Age,Caste,Religion,Hname,City,District,State,pin,Year,Qualification)"
  10. + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  11. PreparedStatement ps = con.prepareStatement(str);
  12. ps.setString(1, txtAdNo.getText());
  13. ps.setString(2, txtName.getText());
  14. ps.setString(3, txtPhNo.getText());
  15. ps.setString(4, cmbSex.getSelectedItem().toString());
  16. ps.setString(5, txtFatherName.getText());
  17. ps.setString(6, txtOccupation.getText());
  18. ps.setString(7, txtMotherName.getText());
  19. ps.setString(8, txtDOB.getText());
  20. ps.setString(9, txtAge.getText());
  21. ps.setString(10, txtCaste.getText());
  22. ps.setString(11, txtReligion.getText());
  23. ps.setString(12, txtHouseName.getText());
  24. ps.setString(13, txtCity.getText());
  25. ps.setString(14, txtDistrict.getText());
  26. ps.setString(15, txtState.getText());
  27. ps.setString(16, txtPin.getText());
  28. ps.setString(17, txtYear.getText());
  29. ps.setString(18, txtQualification.getText());
  30. ps.executeUpdate();
  31. JOptionPane.showMessageDialog(null, "Registration details successfully updated", "Success", JOptionPane.INFORMATION_MESSAGE);
  32. ClearForm();
  33. }
  34. catch (Exception x) {
  35. JOptionPane.showMessageDialog(null, "Error on database operation,Updation failure", "Error", JOptionPane.ERROR_MESSAGE);
  36. }//inner try catch closed
  37. } catch (Exception ex) {
  38. JOptionPane.showMessageDialog(null, "Error on connection to database, cannot continue updation process", "Error", JOptionPane.ERROR_MESSAGE);
  39. }//outer try catch closed
  40. }//if closed
  41. if (e.getActionCommand().equalsIgnoreCase("Clear")) {
  42. ClearForm();
  43. }//if closed
  44. if (e.getActionCommand().equalsIgnoreCase("Cancel")) {
  45. this.dispose();
  46. }//if closed
  47. }
Add Comment
Please, Sign In to add comment