// 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