An efficient javabea paging for SQL Server

Source: Internet
Author: User
Tags sql
server|sqlserver| paging an efficient JAVABEA paging for SQL Server


<%@ page contenttype= "text/html;charset=gb2312"%>


<%@ page import= "ite.com.*,java.util.*"%>


<title> Paging display forsqlserver using select paging </title>


<style type= "Text/css" >


<!--


Table {background-color: #000000;}


td {Background-color: #FFFFFF;}


-->


</style>


<%


java.util.List rstlist=new java.util.ArrayList ();


//database connection pool initialization


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;


}


}


//Use Select to achieve paging display


//string sql=select Top per page display number of records * FROM TableName where ID is not in (select top display number of records * (show current page-1) ID from tablename)


String sql= ' select top ' +pagesize+ ' * from iokecontent where ID is not ' in ' (select Top ' +pagesize* (pageno-1) + "ID from Iok EContent where iokesort=54 ORDER by id DESC) and iokesort=54 the ORDER by id DESC ";


Rstlist=dbm.querybypage_sql_quick (SQL);





out.println ("<table border=0 cellpadding=1 cellspacing=1");


out.println ("<tr><td> field one </td><td> field two </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) + "> Prev </a>");


out.println ("<a href=selectpage.jsp?pageno=" + (pageno+1) + "> next page </a>");





%>











Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.