- publicList<Product>getProducts(intpageNo,intpageSize)
- {
- Connectionconn=null;
- ResultSetrs=null;
- List<Product>list=newArrayList<Product>();
- conn=DB.getConn();
- Stringsql="select*fromproductlimit"+(pageNo-1)*pageSize+","+pageSize;
- rs=DB.executeQuery(conn,sql);
- try
- {
- while(rs.next())
- {
- Productp=newProduct();
- 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.setCategoryId(rs.getInt("categoryid"));
- p.setPdate(rs.getTimestamp("pdate"));
- list.add(p);
- }
- }catch(SQLExceptione)
- {
- e.printStackTrace();
- }
- finally
- {
- DB.closeRs(rs);
- DB.closeConn(conn);
- }
- returnlist;
- }
在MYSQL中实现分页显示的代码--SHOPPING
最新推荐文章于 2025-03-17 20:02:39 发布