Ejemplo n.º 1
0
  public static void update(User user) throws SQLException {
    String sql =
        "UPDATE user SET login = ?, nom = ?, prenom = ?, email = ?, password = ?, est_actif = ? WHERE id_user = ?";
    PreparedStatement ps = getConnection().prepareStatement(sql);
    ps.setString(1, user.getLogin());
    ps.setString(2, user.getNom());
    ps.setString(3, user.getPrenom());
    ps.setString(4, user.getEmail());
    ps.setString(5, user.getPassword());
    ps.setBoolean(6, user.estActif());

    ps.setInt(7, user.getIdUser());
    ps.executeUpdate();
    ps.close();
  }
Ejemplo n.º 2
0
  public static void insert(User user) throws SQLException {
    String sql =
        "INSERT INTO user (id_user, login, nom, prenom, password, email, est_actif, id_statut) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)";
    PreparedStatement ordre = getConnection().prepareStatement(sql);
    ordre.setString(1, user.getLogin());
    ordre.setString(2, user.getNom());
    ordre.setString(3, user.getPrenom());
    ordre.setString(4, user.getPassword());
    ordre.setString(5, user.getEmail());
    ordre.setBoolean(6, user.estActif());
    ordre.setInt(7, user.getStatut().getId_statut());

    ordre.executeUpdate();
    ordre.close();
  }