Language/Java, Jsp

JSP ResultSet

__bo0o_ 2022. 4. 6. 22:16
// Usage

ResultSet rst = stmt.executeQuery(sql);

rst.first() // 커서를 처음으로
rst.last() // 커서를 제일 뒤로

rst.next() // 커서를 다음으로
rst.previous() // 커서를 이전으로

rst.isFirst() // 커서가 처음인지
rst.isLast() // 커서가 마지막인지

rst.getRow() // 현재 커서가 가리키고 있는 row 번호

rst.beforeFirst() // 커서를 제일 위로(빈 공간)
rst.afterLast() // 커서를 제일 뒤로

 

<%
    String sql_example = "select ... ";
    ResultSet rs_example = stmt.executeQuery(sql_example);
    while(rs_example.next()) {

        ...

        %>
            <%=rs_example.getInt("c_type")%>
            <%=rs_example.getString("c_name")%>
        <%
    }
%>

 

https://kbseok.tistory.com/entry/JSP-ResultSet-%EB%8B%A4%EB%A3%A8%EA%B8%B0

반응형