<%@page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*" errorPage=""%>
<html>
<head>
<title>留言本</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/web.css" rel="stylesheet" type="text/css">
</head>
<body>
<jsp:useBean id="wu" scope="page" class="wu.jdbc" />
<%
Connection con = wu.getConn();
Statement stmt = con.createStatement();
String sql = "select * from liuyan_temp order by id desc";
ResultSet rs = stmt.executeQuery(sql);
String pages = request.getParameter("page");
int pageInt = 1, i = 1;
if (pages == null) {
} else {
pageInt = Integer.parseInt(pages);
}
while (i < 20 * (pageInt - 1) && rs.next()) {
i++;
}
%>
<%
sql = "select count(*) from liuyan_temp";
rs = stmt.executeQuery(sql);
while (rs.next())
i = rs.getInt(1);
%>
总共有留言<%=i%>条/<%=(i+19)/20%>页
<%
try {
rs.close();
stmt.close();
con.close();
} catch (Exception ex) {
}
%>
</body>
</html>
源代码:http://pan.baidu.com/share/link?shareid=455134&uk=3878681452
数据库分页读取之一
最新推荐文章于 2021-06-22 06:30:30 发布