package com.jc.domo.beans;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class PaginationBean{
private int curPage=1;
private int maxPage;
private int maxRowCount;
private int rowsPerPage=5;
public java.util.Vector data;
public void setMaxPage(int maxPage){
this.maxPage=maxPage;
}
public void setcurPage(int curPage){
this.curPage=curPage;
}
public void setMaxRowCount(int maxRowCount){
this.maxRowCount=maxRowCount;
}
public void setRowsPerPage(int rowsPerPage){
this.rowsPerPage=rowsPerPage;
}
public int getMaxPage(){
return this.maxPage;
}
public int getCurPage() {
return this.curPage;
}
public int getMaxRowCount(){
return this.maxRowCount;
}
public int getRowsPerPage(){
return this.rowsPerPage;
}
}
PaginationDao.java
package com.jc.domo.dao;
import java.sql.*;
import java.util.*;
import com.jc.domo.conns.PaginationConn;
import com.jc.domo.beans.PaginationBean;
public class PaginationDao{
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
PaginationBean pb=new PaginationBean();
public PaginationBean getResult(String page)throws Exception{
Vector v=new Vector();
int pageNum=Integer.parseInt(page);
String SQL="select top "+pageNum*pb.getRowsPerPage()+"* from productInfo";
int i=0;
try
{
conn=PaginationConn.getPC().getConn();
pstmt=conn.prepareStatement(SQL);
rs=pstmt.executeQuery();
while(rs.next())
{
if(i>(pageNum-1)*pb.getRowsPerPage()-1)
{
Object[] obj=new Object[5];
obj[0]=rs.getString(2);
obj[1]=rs.getString(3);
obj[2]=rs.getInt(4);
obj[3]=rs.getString(5);System.out.println("akjdklf");
obj[4]=rs.getString(6);
v.add(obj);
}
i++;
}
rs.close();
pstmt.close();