Jsp is as follows:
**********************
<% @ Page language = "java" import = "java. util. *, java. SQL. *" %>
<% @ Page contentType = "text/html; charset = gb2312" %>
<Jsp: useBean id = "cn" scope = "page" class = "myConnection. Conn"/> <! -- Reference the bean for database operations and complete it by yourself. I will not go into details here -->
<%
Int curpage = 1; // current page
Int page_record = 20; // number of records displayed on each page
// Use the following method (SQL query is completed, and the speed is fast)
Curpage = Integer. parseInt (request. getParameter ("page"); // obtain the passed value, the page to be displayed
ResultSet rs = cn. rsexecuteQuery ("select top" + page_record + "* from tablename where id not in (select top" + (curpage * page_record) + "id from tablename order by id desc) order by id desc ");
// This query statement returns the 20 records on the 1000 page to be displayed. The general idea is that subqueries exclude all records before the records to be displayed, the parent query sorts the remaining records in descending order.
While (rs. next ){
Out. println (rs. getInt ("id"). toString ());
}
Rs. close ();
%>