zoukankan      html  css  js  c++  java
  • 关系管理系统:CustomerDaoimpl中添加用户分页显示getPageData()

    //获取分页数据
        public List<Customer> getPageData(int startindex,int pagesize){
            Connection conn = null;
            PreparedStatement st = null;
            ResultSet rs = null;
            try{
                conn = JdbcUtils.getConnection();
                String sql = "select * from customer limit ?,?";
                st = conn.prepareStatement(sql);
                st.setInt(1, startindex);
                st.setInt(2, pagesize);
                
                rs = st.executeQuery();
                List list = new ArrayList();
                while(rs.next()){
                    Customer c = new Customer();
                    c.setBirthday(rs.getDate("birthday"));
                    c.setCellphone(rs.getString("cellphone"));
                    c.setDescription(rs.getString("description"));
                    c.setEmail(rs.getString("email"));
                    c.setGender(rs.getString("gender"));
                    c.setId(rs.getString("id"));
                    c.setName(rs.getString("name"));
                    c.setPreference(rs.getString("preference"));
                    c.setType(rs.getString("type"));
                    list.add(c);
                }
                
                return list;
            }catch (Exception e) {
                throw new DaoException(e);
            }finally{
                JdbcUtils.release(conn, st, rs);
            }
        }
        
  • 相关阅读:
    814. Binary Tree Pruning
    50. Pow(x, n)
    698. Partition to K Equal Sum Subsets
    416. Partition Equal Subset Sum
    150. Evaluate Reverse Polish Notation
    322. Coin Change
    Vulnerable Kerbals CodeForces
    D. Domino for Young
    C. Long Beautiful Integer
    B. Modulo Equality
  • 原文地址:https://www.cnblogs.com/lichone2010/p/3175872.html
Copyright © 2011-2022 走看看