MVC패턴 데이터베이스 관리작업

조회수 454회

Connection conn = null; PreparedStatement pstmt = null; String jdbc_driver = "com.mysql.cj.jdbc.Driver"; String jdbc_uri = "jdbc:mysql://localhost/jspdb?useSSL=false&serverTimezone=UTC";

public int login_check(MemVO vo) {
    int check = -1;

    connect();
    String sql = "select * from MemberList where id=?";
    try {
        pstmt = conn.prepareStatement(sql);
        pstmt.setString(1, vo.getId());
        ResultSet rs = pstmt.executeQuery();

        while(rs.next()) {
            if(vo.getPasswd().equals(rs.getString("passwd"))) {
                check = rs.getInt("score");
            }
        }
        rs.close();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        disconnect();
    }

    return check;
}

회원이 로그인을 시도하면 데이터베이스에 있는 관리 목록 중 id로 먼저 접근을 하고 거기서 패스워드와 일치하면 score을 반환하는 함수입니다. (DB에 있는 score값은 0입니다.) while(rs.next()) { if(vo.getPasswd().equals(rs.getString("passwd"))) { check = rs.getInt("score"); } } 이부분에 들어가지가 않네요. 오류메시지도 안뜨고 해서 어떻게 해야하는지 모르겠습니다.

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)