The example explains how to use JSP to obtain the data in the ResultSet result set, and the example describes the resultset
Obtain all records
<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. SQL. *" %> <! DOCTYPE html>
Obtain records of specified fields in all records
<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. SQL. *" %> <! DOCTYPE html>
Obtain the record of the specified start position and number of entries
<% @ Page language = "java" contentType = "text/html; charset = gb2312" %> <% @ page import = "java. SQL. *" %> <! DOCTYPE html>
Traverse the data in the ResultSet and convert it to a table
After searching for the data in the ResultSet on the Internet for a long time and filling it in a webpage table in sequence, it is said that the ResultSet data is converted to a two-dimensional array and then output in sequence, however, the storage size of the two arrays needs to be specified in advance, which is inconvenient for amplification. Use the following method:
while(rs.next()){ out.println("<tr><td>"+rs.getString(1)+"</td><td>" +rs.getString(2)+"</td><td>"+rs.getString(3)+"</td><td>" +rs.getString(4)+"</td><td>"+rs.getString(5)+"</td><td>"+rs.getString(6)+"</td><td>" +rs.getString(7)+"</td><td>"+rs.getString(8)+"</td><td>"+rs.getString(9)+"</td><td>" +rs.getString(10)+"</td><td>"+rs.getString(11)+"</td><td>"+rs.getString(12)+"</td><tr>");}