//本程序使用了一個類反射的類,可以自動將查詢出來的值填充到值對象裡。
//這個類可以參見ibm的文章:使用類反射機制簡化struts的開發.
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";// 當前頁
private int i_page=1;//當前頁
private int i_page_count=10;//每頁顯示條數
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(*)語句
private ResultSet rst=null;
private PreparedStatement stm=null;
private Collection result_c=null;
private String s_null="無";
///////////////////////////輸入值///////////////////////////////
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;
}
//////////////////////////////////////返回值///////////////////////////////////////////
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;
}
////////////////////////////////////////操 作///////////////////////////////////////////////
private String b_string,f_string;
private String comsql;
private void CountPage() throws Exception