/**
  * 从数据库里查询总的记录数并计算总页数,回写进分页参数<code>PageParameter</code>,这样调用 者就可用通过 分页参数 <code>PageParameter
  * </code>获得相关信息。
  *
  * @param sql
  * @param connection
  * @param mappedStatement
  * @param boundSql
  * @param page
  */
 private void setPageParameter(
     String sql,
     Connection connection,
     MappedStatement mappedStatement,
     BoundSql boundSql,
     PageParameter page) {
   // 记录总记录数
   String countSql = "select count(0) as total from (" + sql + ")  tt";
   PreparedStatement countStmt = null;
   ResultSet rs = null;
   try {
     countStmt = connection.prepareStatement(countSql);
     setParameters(countStmt, mappedStatement, boundSql);
     rs = countStmt.executeQuery();
     int totalCount = 0;
     if (rs.next()) {
       totalCount = rs.getInt(1);
     }
     page.setTotalElements(totalCount);
     //			int totalPage = totalCount / page.getPageSize() + ((totalCount % page.getPageSize() == 0)
     // ? 0 : 1);
     //			page.setTotalPage(totalPage);
   } catch (SQLException e) {
     logger.error("Ignore this exception", e);
   } finally {
     try {
       rs.close();
     } catch (SQLException e) {
       logger.error("Ignore this exception", e);
     }
     try {
       countStmt.close();
     } catch (SQLException e) {
       logger.error("Ignore this exception", e);
     }
   }
 }