The following articles mainly describe the actual application code correctly displayed by page in the MySQL database, as shown below, the following is a description of the actual application code correctly displayed by page in the MySQL database. I hope it will be helpful for you in your future studies.
- public List<Product> getProducts(int pageNo, int pageSize)
- {
- Connection conn=null;
- ResultSet rs=null;
- List<Product> list=new ArrayList<Product>();
- conn=DB.getConn();
- String sql="select * from product limit "+(pageNo-1)*pageSize+","+pageSize;
-
- rs=DB.executeQuery(conn, sql);
- try
- {
- 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.setCategoryId(rs.getInt("categoryid"));
- p.setPdate(rs.getTimestamp("pdate"));
- list.add(p);
- }
- } catch (SQLException e)
- {
- e.printStackTrace();
- }
- finally
- {
- DB.closeRs(rs);
- DB.closeConn(conn);
- }
- return list;
- }
The above content describes the code that is displayed by page in the MySQL database. I hope it will help you in this regard.