Ejemplo n.º 1
0
  @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
    }
  }
Ejemplo n.º 2
0
 @Override
 public void addAddress(Address address) {
   System.out.println("addAddress_***************************");
   customer.setAddress(address);
 }
Ejemplo n.º 3
0
 @Override
 public void addLoginInfos(Login login) {
   System.out.println("addLogin_***************************");
   customer.setLogin(login);
 }