code: private void setPageTotalCount(Connection connection, MappedStatement mappedStatement, BoundSql boundSql) {
          PreparedStatement preparedStatement = null;
          ResultSet resultSet = null;
          try {
              preparedStatement = connection.prepareStatement(createCountSql(boundSql.getSql()));
              ParameterHandler parameterHandler = new DefaultParameterHandler(mappedStatement, boundSql.getParameterObject(), boundSql);
              parameterHandler.setParameters(preparedStatement);
              resultSet = preparedStatement.executeQuery();
              if (resultSet.next()) {
                  ((PageEntity) boundSql.getParameterObject()).setTotalCount(resultSet.getLong(1));
              }
              if (resultSet != null) resultSet.close();
              if (preparedStatement != null) preparedStatement.close();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }
docs: 执行总条数查询并设置值
  
  @param connection
  @param mappedStatement
  @param boundSql