Esempio n. 1
0
  public void userAdd(UserDTO user) {

    try (Connection conn = Conn.getConnection();
        PreparedStatement pstmt = conn.prepareStatement("insert into user values(?,?,?,?)"); ) {
      pstmt.setInt(1, user.getUid());
      pstmt.setString(2, Sha256.encrypt(user.getPassword()));
      pstmt.setString(3, user.getName());
      pstmt.setString(4, user.getAuth());
      pstmt.executeUpdate();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 2
0
  public void userUpdate(UserDTO user) {

    try (Connection conn = Conn.getConnection();
        PreparedStatement pstmt =
            conn.prepareStatement("update user set name=?,password=? where user_id=?"); ) {
      pstmt.setString(1, user.getName());
      pstmt.setString(2, Sha256.encrypt(user.getPassword()));
      pstmt.setInt(3, user.getUid());

      pstmt.executeUpdate();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }