Guest User

Untitled

a guest
Mar 9th, 2016
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 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. Connection connection = null;
  12. Statement stmt = null;
  13.  
  14. if (emailcon.equals(email)) {
  15. if (passwordcon.equals(password)) {
  16. try {
  17. Class.forName("com.mysql.jdbc.Driver");
  18. connection = DriverManager
  19. .getConnection("jdbc:mysql://localhost:3306/healthapp", "root", "");
  20.  
  21. stmt = connection.createStatement();
  22. stmt.execute("INSERT INTO DOCTOR (DOCTOR_TITLE,DOCTOR_NAME,DOCTOR_SURNAME,DOCTOR_DOB,DOCTOR_EMAIL,DOCTOR_PASSWORD,DOCTOR_TELNUMBER,HOSPITAL_CODE) "
  23. + "VALUES ('" + title + "','" + name + "','" + surname + "','" + year + "-" + month + "-" + day + "','" + email + "','" + password + "','+353868728668','9')");
  24. } catch (Exception e) {
  25. e.printStackTrace();
  26. } finally {
  27. try {
  28. stmt.close();
  29. connection.close();
  30. } catch (Exception e) {
  31. e.printStackTrace();
  32. }
  33. }
  34.  
  35. LayoutManager layout = getParent().getLayout();
  36. if (layout instanceof CardLayout) {
  37. CardLayout cl = (CardLayout) layout;
  38. cl.show(getParent(), "WELCOME");
  39. }
  40. }
  41. else{
  42. JOptionPane.showMessageDialog(null, "passwords do not match, please try again");
  43. }
  44. } else {
  45. JOptionPane.showMessageDialog(null, "emails do not match, please try again");
  46. }
Add Comment
Please, Sign In to add comment