網頁特效phttp://www.111cn.net/網頁特效p.html target=_blank >jsp教程 大資料量分頁代碼
/*
分頁思路是
首先在資料庫教程裡分頁 比如分1000條一頁 (即一次查詢1000條), 然後,從返回的1000條資料裡進行記錄集分頁
*/
public string getcountsql(string strwhere){
string sqlstr ="select count(*) from table";
if(!"".equals(strwhere) && strwhere != null){
sqlstr =sqlstr+" where "+strwhere;
}
return sqlstr;
}
// 記錄sql:currpage當前頁;rowsperpage每頁顯示多少行www.111cn.net
public string getlistsql(int currpage,string strwhere,int rowsperpage){
string sqlstr="select top "+rowsperpage+" id,name" ;
sqlstr = sqlstr + " from table";
sqlstr = sqlstr + " where (id not in(select top " + rowsperpage * (currpage - 1);
if("".equals(strwhere)){
sqlstr = sqlstr + " id from tbdaby order by id desc)) ";
}
else{
sqlstr = sqlstr + " id from tbdaby where " +strwhere+ " order by id desc)) and "+strwhere;
}
sqlstr = sqlstr + " order by id desc ";
return sqlstr;
}
//改成stringbuffer連接字串。111cn.net
//網