java.sql.SQLException:No value specified for parameter ~~
해당 에러는 PreparedStatement 사용 시 나오는
또한, 헷갈리고 착각해서 자주 나오는 고치기 쉬운(?) 에러다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <% String userid = request.getParameter("id"); String userpw = request.getParameter("pw"); String query = "SELECT id, name, birth FROM members WHERE id=? AND passwd=?"; PreparedStatement pstmt = dbconn.preparedStatement(query); pstmt.setString(1, userid); ResultSet rs = pstmt.executeQuery(); if(rs.next()){ // 이하 공백 } %> | cs |
저렇게 쿼리에선 인자를 두 개나 받고 있으면서 하나만 넣어주면 생기는 에러다.
저런 경우에는
pstmt.setString(2, userpw);
와 같이 두 번째 인자에도 값을 넣어줘야한다.
또한,
java.sql.SQLException:No value specified for parameter 2
두 번째 인자 값이므로, parameter 2 라고 에러가 발생한다.
'Web Programming > JSP' 카테고리의 다른 글
[JSP]PSQLException: ResultSet not positioned properly, perhaps you need to call next 해결방법 (0) | 2017.05.11 |
---|