Advertisement
Guest User

Untitled

a guest
Aug 11th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. name = full_name_input.getText();
  2.  
  3. Fname = father_name_input.getText();
  4.  
  5. cnic = father_cnic_input.getText();
  6.  
  7. DOB = Integer.parseInt(DOB_input.getText());
  8.  
  9. Class_V = Integer.parseInt(class_input.getText());
  10.  
  11. prsnt_add = present_add_input.getText();
  12.  
  13. city = city_input.getText();
  14.  
  15. province = radio_text;
  16.  
  17. Connection conn = null;
  18.  
  19. PreparedStatement pst = null;
  20.  
  21. try
  22. {
  23. Class.forName("com.mysql.jdbc.Driver");
  24.  
  25. conn = DriverManager.getConnection("jdbc:mysql:///UserDetails", "root", "sahanj");
  26.  
  27. pst = conn.prepareStatement("insert into UserDetails values (?,?,?,?,?,?,?,?)");
  28.  
  29. pst.setString(1, name);
  30.  
  31. pst.setString(2, Fname);
  32.  
  33. pst.setString(3, cnic);`enter code here`
  34. pst.setInt(4, DOB);
  35.  
  36. pst.setInt(5, Class_V);
  37.  
  38. pst.setString(6, prsnt_add);
  39.  
  40. pst.setString(7, city);
  41.  
  42. pst.setString(8, province);
  43.  
  44. int x = pst.executeUpdate();
  45.  
  46. if (x>0)
  47. {
  48. JOptionPane.showMessageDialog(null, "Record Saved !n");
  49. }
  50. else
  51. {
  52. JOptionPane.showMessageDialog(null, "Data Not Saved !n");
  53. }
  54. }
  55.  
  56. catch(Exception e)
  57. {
  58. JOptionPane.showMessageDialog(null, e);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement