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);
            }
        }
        
  • 相关阅读:
    [haoi2015]T1
    [haoi2014]走出金字塔
    [haoi2014]穿越封锁线
    [haoi2014]遥感监测
    [haoi2012]高速公路
    [haoi2012]容易题
    [haoi2008]排名系统
    【bzoj1014】[JSOI2008]火星人prefix
    0916解题报告
    生成树计数问题
  • 原文地址:https://www.cnblogs.com/lichone2010/p/3175872.html
Copyright © 2011-2022 走看看