int pageSize=3;//一页显示几条记录
int pageNow=1;//希望显示第几条
int rowCount=0;//共有几条记录(查表)
int pageCount=0;//共有几页(计算)
com.cric.javaBean.DBUtils db=new com.cric.javaBean.DBUtils();
try {
java.sql.Connection con=db.getConnection();
String sqlStr="select count(*) from userType";
java.sql.PreparedStatement ps = con.prepareStatement(sqlStr);
ResultSet rs = ps.executeQuery();
if(rs.next())
{
rowCount=rs.getInt(1);
}
System.out.println(rowCount);
response.getWriter().write(rowCount);
//计算pageCount
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
String sqlStr2="select top "+pageSize+" * from userType where userTypeId not in(select top "+pageSize*(pageNow-1)+" userTypeId from userType)";
while(rs.next()){
}