1.确定数据的数量,示例如下:
public int getTotalCount() {
// TODO Auto-generated method stub
int totalCount=0;
String sql="select count(*) from news_detail";
Object[] params={};
ResultSet rs=this.executeSQL(sql, params);
try {
while(rs.next()){
totalCount=rs.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
//释放资源
this.closeResource();
}
return totalCount;
}
2.确定显示的页数,示例:
private void setTotalPageCountByRs(){
if(this.recordCount%this.pageSize==0){
this.totalPageCount=this.recordCount/t