Advertisement
Guest User

Untitled

a guest
Mar 9th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. String title = (String) titleCB.getSelectedItem();
  2. String name = nameTF.getText();
  3. String surname = surnameTF.getText();
  4. String year = (String) yearCB.getSelectedItem();
  5. String month = (String) monthCB.getSelectedItem();
  6. String day = (String) dayCB.getSelectedItem();
  7. String email = emailTF.getText();
  8. String password = new String(passwordPF.getText());
  9. String emailcon = emailconfirmTF.getText();
  10. String passwordcon = new String(passwordconfirmPF.getText());
  11. String city = cityTF.getText();
  12. String country = (String) countryCB.getSelectedItem();
  13. String address = addressTF.getText();
  14.  
  15. Connection connection = null;
  16. Statement stmt = null;
  17.  
  18. if (emailcon.equals(email)) {
  19. if (passwordcon.equals(password)) {
  20. try {
  21. Class.forName("com.mysql.jdbc.Driver");
  22. connection = DriverManager
  23. .getConnection("jdbc:mysql://localhost:3306/healthapp", "root", "");
  24.  
  25. stmt = connection.createStatement();
  26. stmt.execute("INSERT INTO PATIENT (PATIENT_TITLE,PATIENT_NAME,PATIENT_SURNAME,PATIENT_DOB,PATIENT_EMAIL,PATIENT_PASSWORD,PATIENT_ADDRESS,PATIENT_CITY,PATIENT_COUNTRY) "
  27. + "VALUES ('" + title + "','" + name + "','" + surname + "','" + year + "-" + month + "-" + day + "','" + email + "','" + password + "','"+address+"', '"+city+"','"+country+"')");
  28. } catch (Exception e) {
  29. e.printStackTrace();
  30. } finally {
  31. try {
  32. stmt.close();
  33. connection.close();
  34. } catch (Exception e) {
  35. e.printStackTrace();
  36. }
  37. }
  38.  
  39. LayoutManager layout = getParent().getLayout();
  40. if (layout instanceof CardLayout) {
  41. CardLayout cl = (CardLayout) layout;
  42. cl.show(getParent(), "WELCOME");
  43. }
  44. }
  45. else{
  46. JOptionPane.showMessageDialog(null, "passwords do not match, please try again");
  47. }
  48. } else {
  49. JOptionPane.showMessageDialog(null, "emails do not match, please try again");
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement