diff --git a/src/main/java/org/s4s/dao/RegistrationDAO.java b/src/main/java/org/s4s/dao/RegistrationDAO.java index cdc41f3b72389ea1de0bd4fead3fb6cd02efaef8..bcd68b290c25e7f426e95a6e34b6196e04fc969b 100644 --- a/src/main/java/org/s4s/dao/RegistrationDAO.java +++ b/src/main/java/org/s4s/dao/RegistrationDAO.java @@ -16,7 +16,7 @@ import org.s4s.services.db.JDBCConnection; */ public class RegistrationDAO extends AbstractDatabaseClass { - Statement st = JDBCConnection.getInstance().getStatement(); + Statement st; String sql_update; public void addUser(String benutzer, String nachname, String vorname, java.util.Date gebDate, int fBereich, String email, String emailwdh, String passwort, String passwortWdh) { @@ -24,7 +24,7 @@ public class RegistrationDAO extends AbstractDatabaseClass { sql_update = "INSERT INTO \"ERR\".\"user\"(benutzername, nachname, vorname, geburtsdatum, fachbreichid, email, passwort)" + "VALUES(\'" + benutzer + "\', \'" + nachname + "\', \'" + vorname + "\', \'" + gebDate + "\', \'" + fBereich + "\', \'" + email + "\', \'" + passwort + "\')"; - int exe = st.executeUpdate(sql_update); + int exe = JDBCConnection.getInstance().getStatement().executeUpdate(sql_update); if(exe < 0) { throw new WrongInputException("Wrong Input!"); } diff --git a/src/main/java/org/s4s/dao/impl/RegistrationControl.java b/src/main/java/org/s4s/dao/impl/RegistrationControl.java index 7e1a1925dbfb01e4eb8105be5286017e1fce530d..5283da00b58d8c5eb51f34adcecb1c81cee78def 100644 --- a/src/main/java/org/s4s/dao/impl/RegistrationControl.java +++ b/src/main/java/org/s4s/dao/impl/RegistrationControl.java @@ -19,10 +19,7 @@ import org.s4s.exceptions.WrongInputException; */ public class RegistrationControl { //User-Block - private static String nachname; - private static String vorname; private static String email; - private static String passwort; private static RegistrationDAO regDAO = new RegistrationDAO(); @@ -59,14 +56,14 @@ public class RegistrationControl { throw new WrongInputException("Vorname enthält ungültige Zeichen!"); } - if (!passwordValidator()) { + if (!passwordValidator(passwort)) { throw new WrongInputException("Passwort ungültig!"); } } catch(WrongInputException w) { w.printStackTrace(); System.out.println("Exception occur: " + w.getMessage()); } - regDAO.addUser(benutzer, nachname, vorname, gebDate, fBereich, email, emailwdh, passwort, passwortWdh); + regDAO.addUser(benutzer, nachname, vorname, gebDate, fBereich, email, emailwdh, passwort, passwortWdh); } @@ -85,7 +82,7 @@ public class RegistrationControl { return EmailValidator.getInstance().isValid(email); } - public static boolean passwordValidator() { + public static boolean passwordValidator(String passwort) { return passwort.length() > 8; /* String regex = "^.*(?=.{8,})(?=..*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&+=]).*$"; diff --git a/src/main/java/org/s4s/gui/views/RegistrierungView.java b/src/main/java/org/s4s/gui/views/RegistrierungView.java index 47e424a476689d374d7307e1734f696ec4663b08..0b341786285d2c0e54cac0e5bb71ddf80df80e9a 100644 --- a/src/main/java/org/s4s/gui/views/RegistrierungView.java +++ b/src/main/java/org/s4s/gui/views/RegistrierungView.java @@ -51,6 +51,7 @@ public class RegistrierungView extends TemplateView implements View { content.addComponent(benutzername); DateField bday = new DateField("Geburtstag"); + bday.setDateFormat("YYYY-MM-DD"); content.addComponent(bday); TextField nachnameTxt = new TextField("Nachname:");