PSQLException: ResultSet not positioned properly, perhaps you need to call next
이 에러는, ResultSet 객체 사용을 잘 못 했을 때 발생되는 에러다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <% String id = ""; String query = "SELECT id FROM users"; PreparedStatement pstmt = conn.preparedStatement(query); ResultSet rs = pstmt.executeQuery(); if(rs!=null){ id = rs.getString(1); } rs.next(); id = rs.getString(1); %> | cs |
이런 식으로 작성하면 ResultSet 객체를 잘못 사용했기 때문에 위의 에러가 발생한다.
따라서, 이렇게 고쳐주자
1 2 3 4 5 6 7 8 9 10 11 | <% String id = ""; String query = "SELECT id FROM users"; PreparedStatement pstmt = conn.preparedStatement(query); ResultSet rs = pstmt.executeQuery(); if(rs.next()){ id = rs.getString(1); } %> | cs |
'Web Programming > JSP' 카테고리의 다른 글
[JSP]java.sql.SQLException:No value specified for parameter 해결방법 (0) | 2017.05.10 |
---|