A common JSP paging Program

Source: Internet
Author: User

// This program uses a class reflection class, which can automatically fill the queried value into the value object.
// This class can be found in the ibm article: using the class reflection mechanism to simplify struts development.

Package com. lyjWeb. wyhn. common;


Import java. SQL .*;
Import com. lyjWeb. common .*;
Import java. util .*;

Public class Fenye {
 
Private Connection con = null;
Private String SQL = "";
Private String page = "1"; // current page
Private int I _page = 1; // current page
Private int I _page_count = 10; // number of entries per page
Private String nextpage, prepage, sumpage, sumcount;
 
Private String SQL _select, SQL _from, SQL _where, SQL _order;
Private String SQL _pre = "";
Private String SQL _count = ""; // count (*) Statement
Private ResultSet rst = null;
Private PreparedStatement stm = null;
 
Private Collection result_c = null;
 
Private String s_null = "NONE ";
 
/// // Input value /////////// ////////////////////
Public void setConnection (Connection con)
{
This. con = con;
}

Public void setSql (String SQL _select, String SQL _from, String SQL _where, String SQL _order)
{
// This. SQL = SQL;
This. SQL _select = SQL _select;
This. SQL _from = SQL _from;
This. SQL _where = SQL _where;
This. SQL _order = SQL _order;
This. SQL _count = "select count (*)" + SQL _from + "" + SQL _where;
This. SQL = SQL _select + "" + SQL _from + "" + SQL _where + "" + SQL _order;
}
 
Public void setStm (PreparedStatement stm)
{
This. stm = stm;
}
 
Public void setPage (String p)
{
If (p = null)
{
This. page = "1 ";
This. I _page = 1;
}
Else
{
P = p. trim ();
If (p. equals ("") p = "1 ";
This. page = p;
This. I _page = Integer. parseInt (this. page );
}

}
 
Public void setPageCount (int pcount)
{
This. I _page_count = pcount;
}

Public void setSqlPre (String sqlpre)
{
This. SQL _pre = sqlpre;
}

Public void setS_null (String s_null)
{
This. s_null = s_null;
}
/// // Return value/ //////////////////////////////////////// //
Public ResultSet getRst ()
{
Return rst;
}
 
Public String getPage ()
{
Return page;
}

Public String getNextPage ()
{
Return nextpage;
}
 
Public String getPrePage ()
{
Return prepage;
}
 
Public String getSumPage ()
{
Return sumpage;
}
 
Public String getCount ()
{
Return sumcount;
}
 
Public Collection getCollection ()
{
Return result_c;
}
 
//////////////////////////////////////// Operation ////////////////////////////////////// /////////
Private String B _string, f_string;
Private String comsql;
 
Private void CountPage () throws Exception

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.