コード例 #1
0
ファイル: UserDAO.java プロジェクト: KimSeongIl/SCRSystem
  public UserDTO login(UserDTO user) {
    UserDTO dto = null;
    try (Connection conn = Conn.getConnection();
        PreparedStatement pstmt =
            conn.prepareStatement(
                "select user_id,name,auth from user where user_id=? and password=?"); ) {
      pstmt.setInt(1, user.getUid());
      pstmt.setString(2, Sha256.encrypt(user.getPassword()));
      // pstmt.setString(2, user.getPassword());
      try (ResultSet rs = pstmt.executeQuery(); ) {
        if (rs.next()) {
          dto = new UserDTO();
          dto.setUid(rs.getInt("user_id"));
          dto.setName(rs.getString("name"));
          dto.setAuth(rs.getString("auth"));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return dto;
  }
コード例 #2
0
ファイル: UserDAO.java プロジェクト: KimSeongIl/SCRSystem
  public boolean userDelete(UserDTO user) {
    try (Connection conn = Conn.getConnection();
        PreparedStatement pstmt = conn.prepareStatement("delete from user where user_id=?"); ) {

      pstmt.setInt(1, user.getUid());
      pstmt.executeUpdate();
    } catch (Exception e) {
      return false;
    }
    return true;
  }
コード例 #3
0
ファイル: UserDAO.java プロジェクト: KimSeongIl/SCRSystem
  public void setTempPassword(UserDTO user) {
    try (Connection conn = Conn.getConnection();
        PreparedStatement pstmt =
            conn.prepareStatement("update user set password=? where user_id=?"); ) {

      pstmt.setString(1, Sha256.encrypt(user.getPassword()));
      pstmt.setInt(2, user.getUid());
      pstmt.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #4
0
ファイル: UserDAO.java プロジェクト: KimSeongIl/SCRSystem
  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();
    }
  }
コード例 #5
0
ファイル: UserDAO.java プロジェクト: KimSeongIl/SCRSystem
  public boolean passwordCheck(UserDTO user) {
    boolean check = false;
    try (Connection conn = Conn.getConnection();
        PreparedStatement pstmt =
            conn.prepareStatement("select user_id from user where user_id=? and password=? "); ) {
      pstmt.setInt(1, user.getUid());
      pstmt.setString(2, Sha256.encrypt(user.getPassword()));
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        check = true;
      } else {

        check = false;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return check;
  }
コード例 #6
0
ファイル: UserDAO.java プロジェクト: KimSeongIl/SCRSystem
 public boolean overlapCheck(UserDTO user) {
   boolean check = false;
   try (Connection conn = Conn.getConnection();
       PreparedStatement pstmt =
           conn.prepareStatement("select user_id from user where user_id=?"); ) {
     pstmt.setInt(1, user.getUid());
     try (ResultSet rs = pstmt.executeQuery(); ) {
       if (rs.next()) {
         check = true;
       }
     } catch (Exception e) {
       e.printStackTrace();
       return check;
     }
   } catch (Exception e) {
     e.printStackTrace();
     return check;
   }
   return check;
 }