@Override public void createAccount() { System.out.println("createAccount_***************************"); try { // requête d'insertion. String sql = "INSERT INTO customers (firstname,lastname,username,password,street,zipcode,city)" + " VALUES(?,?,?,?,?,?,?)"; try (PreparedStatement stmt = cn.prepareStatement(sql)) { stmt.setString(1, customer.getFirstname()); stmt.setString(2, customer.getLastname()); stmt.setString(3, customer.getLogin().getUsername()); stmt.setString(4, customer.getLogin().getPassword()); stmt.setString(5, customer.getAddress().getStreet()); stmt.setInt(6, customer.getAddress().getZipcode()); stmt.setString(7, customer.getAddress().getCity()); stmt.executeUpdate(); } } catch (SQLException ex) { Logger.getLogger(AccountCreatorService.class.getName()).log(Level.SEVERE, null, ex); throw new EJBException( ex.getMessage()); // on relance une exception système - PreDestroy n'est pas invoquée } }
@Override public void addAddress(Address address) { System.out.println("addAddress_***************************"); customer.setAddress(address); }
@Override public void addLoginInfos(Login login) { System.out.println("addLogin_***************************"); customer.setLogin(login); }