
package sample.javaBean;
import sample.javaBean.ConnDb;
import java.util.List;
import java.util.ArrayList;
public class Paination {
private int currentPage;
private int totalPages;
private int pageRows=2;
private int totalRows;
private int pageStartRow;
private int pageEndRow;
private boolean hasPreviousPage;
private boolean hasNextPage;
private List<Object[]>totalList;
public void selectBySQL(){//这个方法主要是输出数据库里信息,就是你在 servlet 里
把数据库信息放到 list 里一个道理:
List<Object[]> notes=new ArrayList<Object[]>();
ConnDb con=ConnDb.createInstance();
try{
String sql="select * from tb_type order by type_order";
con.setRs(con.query(sql));
while(con.getRs().next()){
Object[] note=new Object[5];
for(int i=0;i<5;i++){
note[i]=con.getRs().getObject(i+1);
}
notes.add(note);
}
con.getRs().close();
}catch (Exception e){
e.printStackTrace();
}
con.closeCon();
totalList=notes;
initPageBean(totalList,pageRows);
评论1
最新资源