进来看看.
public PageBean listData(String page,int PerPage,String strPageWhere,String strWhereType,String strWhere,String strOrderName,int iOrder,int sqlType)throws Exception{
String strSql = " ";
if(strOrderName== " ")
strOrderName= "id ";
try{
PageBean pageBean=new PageBean(this,PerPage,strPageWhere);
int pageNum=Integer.parseInt(page);
Statement stm = conn.createStatement();
if(sqlType == 1){
strSql = "select top "+pageNum*pageBean.rowsPerPage+ " * from commenttoday ";}
else if(sqlType == 2){
strSql = "select * from commenttoday ";
}
if(strWhereType.equalsIgnoreCase( "search ")){
strSql=strSql+ " where title like '% "+strWhere+ "% ' "+
" or content like '% "+strWhere+ "% ' "+
" or pic like '% "+strWhere+ "% ' ";
}
else if(strWhereType.equalsIgnoreCase( "where ")){
strSql = strSql+ " "+strWhere;
}
switch(iOrder){
case 1:strSql=strSql+ " order by "+strOrderName+ " asc ";break;
case 2:strSql=strSql+ " order by "+strOrderName+ " desc ";break;
}
if(sqlType == 2){
strSql = strSql+ " limit "+pageNum*pageBean.rowsPerPage;
}
ResultSet rst = stm.executeQuery(strSql);
int i = 0;
while(rst.next()){
if (i > (pageNum - 1)*pageBean.rowsPerPage - 1){
Object[] obj = new Object[5];
obj[0] = new Integer(rst.getInt( "id "));
obj[1] = new Integer(rst.getInt( "classId "));
obj[2] = rst.getString( "title ");
obj[3] = rst.getString( "content ");
obj[4] = rst.getString( "pic ");