日期:2014-05-20 浏览次数:21109 次
public List<Product> getProducts(int pageNo, int pageSize) {
Connection conn=null;
ResultSet rs=null;
List<Product> list=new ArrayList<Product>();
try {
conn=DB.getConn();
System.out.println(pageNo);
String sql="select * from product"+pageNo+","+pageSize; rs=DB.executeQuery(conn,sql);
while(rs.next()){
Product p=new Product();
p.setId(rs.getInt("id"));
p.setName(rs.getString("name"));
p.setDescr(rs.getString("descr"));
p.setNormalPrice(rs.getDouble("normalPrice"));
p.setMemberPrice(rs.getDouble("memberprice"));
p.setPdate(rs.getTimestamp("Pdate"));
p.setCategoryId(rs.getInt("categoryId"));
list.add(p);
}
} catch (SQLException e){
e.printStackTrace();
} finally {
DB.closeRs(rs);
DB.closeConn(conn);
}
return list;
}