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"/><!--The bean that references the database operation, do it yourself, and don't repeat it here-->
<%
int curpage=1;//Current Page
int page_record=20;//The number of records displayed per page
Use the following method (SQL query complete, fast)
Curpage=integer.parseint (Request.getparameter ("page"));//Get the passed value, the page that needs to be displayed
ResultSet rs=cn.rsexecutequery (' Select top ' +page_record+ ' * FROM TableName where ID is not in (select Top +) + (curpage*page_re Cord) + "ID from tablename ORDER BY id DESC" () Order by id DESC ");
This query statement gets the 1000 pages of 20 records that you want to display, and the general idea is--the subquery excludes all records before the records that need to be displayed, and the parent queries the remaining records in descending order
while (Rs.next) {
Out.println (Rs.getint ("id"). toString ());
}
Rs.close ();
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service