一种高效的JAVABEA分页FOR SQL SERVER
类别: JSP教程
一种高效的javabea分页For SqlServer
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="ite.com.*,java.util.*"%>
<title>分页显示ForSQLServer使用Select分页</title>
<style type="text/css">
<!--
table { background-color: #000000;}
td {background-color: #FFFFFF;}
-->
</style>
<%
java.util.List rstlist=new java.util.ArrayList();
//数据库连接池初始化
DBManager dbm=new DBManager();
dbm.setDatasource("java:comp/env/jdbc/lerp");
int pagesize=10;
int pageno=0;
if (request.getParameter("pageno")==null){
pageno=1;
}else{
pageno=Integer.parseInt(request.getParameter("pageno"));
if(pageno<=0){
pageno=1;
}
}
//使用Select实现分页显示
//String sql=select top 每页显示记录数 * from tablename where id not in(select top 每页显示记录数*(显示当前页-1) id from tablename)
String sql="select top "+pagesize+" * from iokecontent where id not in(select top "+pagesize*(pageno-1)+" id from iokecontent where iokesort=54 order by id desc) and iokesort=54 order by id desc";
rstlist=dbm.queryByPage_SQL_Quick(sql);
out.println("<table border=0 cellpadding=1 cellspacing=1 width=200>");
out.println("<tr><td>字段一</td><td>字段二</td></tr>");
for(int i=0;i<rstlist.size();i++){
out.println("<tr><td>"+((java.util.ArrayList)rstlist.get(i)).get(0)+"</td><td>"+((java.util.ArrayList)rstlist.get(i)).get(2)+"</td></tr>");
}
out.println("</table>");
out.println("<a href=selectpage.jsp?pageno="+(pageno-1)+">上一页</a>");
out.println("<a href=selectpage.jsp?pageno="+(pageno+1)+">下一页</a>");
%>
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="ite.com.*,java.util.*"%>
<title>分页显示ForSQLServer使用Select分页</title>
<style type="text/css">
<!--
table { background-color: #000000;}
td {background-color: #FFFFFF;}
-->
</style>
<%
java.util.List rstlist=new java.util.ArrayList();
//数据库连接池初始化
DBManager dbm=new DBManager();
dbm.setDatasource("java:comp/env/jdbc/lerp");
int pagesize=10;
int pageno=0;
if (request.getParameter("pageno")==null){
pageno=1;
}else{
pageno=Integer.parseInt(request.getParameter("pageno"));
if(pageno<=0){
pageno=1;
}
}
//使用Select实现分页显示
//String sql=select top 每页显示记录数 * from tablename where id not in(select top 每页显示记录数*(显示当前页-1) id from tablename)
String sql="select top "+pagesize+" * from iokecontent where id not in(select top "+pagesize*(pageno-1)+" id from iokecontent where iokesort=54 order by id desc) and iokesort=54 order by id desc";
rstlist=dbm.queryByPage_SQL_Quick(sql);
out.println("<table border=0 cellpadding=1 cellspacing=1 width=200>");
out.println("<tr><td>字段一</td><td>字段二</td></tr>");
for(int i=0;i<rstlist.size();i++){
out.println("<tr><td>"+((java.util.ArrayList)rstlist.get(i)).get(0)+"</td><td>"+((java.util.ArrayList)rstlist.get(i)).get(2)+"</td></tr>");
}
out.println("</table>");
out.println("<a href=selectpage.jsp?pageno="+(pageno-1)+">上一页</a>");
out.println("<a href=selectpage.jsp?pageno="+(pageno+1)+">下一页</a>");
%>
- 上一篇: 用JAVA实现数据库应用系统
- 下一篇: 数据库乱码解决方案
-= 资 源 教 程 =-
文 章 搜 索