예제 #1
0
 public ResultSet departmentList(Connection con, pageBean pageBean, departmentList department)
     throws Exception {
   StringBuffer sb = new StringBuffer("select * from table_department");
   if (department != null && StringUtil.isNotEmpty(department.getDepartmentInfo())) {
     sb.append(" and departmentInfo like '%" + department.getDepartmentInfo() + "%'");
   }
   if (pageBean != null) {
     sb.append(" limit " + pageBean.getStart() + "," + pageBean.getRows());
   }
   PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
   return pstmt.executeQuery();
 }
예제 #2
0
 public int departmentCount(Connection con, departmentList department) throws Exception {
   StringBuffer sb = new StringBuffer("select count(*) as total from table_department");
   if (StringUtil.isNotEmpty(department.getDepartmentInfo())) {
     sb.append(" and departmentInfo like '%" + department.getDepartmentInfo() + "%'");
   }
   PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
   ResultSet rs = pstmt.executeQuery();
   if (rs.next()) {
     return rs.getInt("total");
   } else {
     return 0;
   }
 }