关系管理系统:CustomerDaoimpl中获取总记录数getTotalrecord()

//得到总记录数
    public int getTotalrecord(){
        Connection conn = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        try{
            conn = JdbcUtils.getConnection();
            String sql = "select count(*) from customer";
            st = conn.prepareStatement(sql);
            rs = st.executeQuery();
            if(rs.next()){
                return rs.getInt(1);
            }
            return 0;
        }catch (Exception e) {
            throw new DaoException(e);
        }finally{
            JdbcUtils.release(conn, st, rs);
        }
    }

 

posted @ 2013-07-07 11:08  亂舞春秋  阅读(250)  评论(0编辑  收藏  举报