title: How to pass several resultsets for single report using JasperReports?
body: <p>In my report I have a set of fields and two datasets. I want to execute three procedure at a time to run a report. First procedure for execute set of fields and remaining two procedure for datasets. I pass one resultset to execute a report is working fine. But I want to pass two more resultset from execute() and port() methods. Is it possible to pass multiple resultset using JRResultSetDataSource or any other option?</p>
  
  <pre><code>public ResultSet execute() throws ClassNotFoundException {
      Statement stmt;
      ResultSet resultset = null;
      Connection con = null;
      try {
          String selectstatement = "CALL P_Select_Salary2 ('2013-01-01', '2013-01-31', 1, 'Salary_OA')";
          Class.forName("com.mysql.jdbc.Driver");
          con = DriverManager.getConnection("jdbc:mysql://localhost:3306/compliance?user=root&amp;password=root");
          stmt = con.createStatement();
          resultset = stmt.executeQuery(selectstatement);
  
      } catch (SQLException e) {
          e.printStackTrace();
      } finally {
          close(con);
          close(resultset);
      }
      return resultset;
  }
  
  public ResultSet port() throws ClassNotFoundException {
      Statement stmt;
      ResultSet resultset = null;
      Connection con = null;
      try {
          String selectstatement = "CALL P_Select_Salary3 ('2013-01-01', '2013-01-31', 1, 'Salary')";
          Class.forName("com.mysql.jdbc.Driver");
          con = DriverManager.getConnection("jdbc:mysql://localhost:3306/compliance?user=root&amp;password=root");
          stmt = con.createStatement();
          resultset = stmt.executeQuery(selectstatement);
  
      } catch (SQLException e) {
          e.printStackTrace();
      } finally {
          close(con);
          close(resultset);
      }
      return resultset;
  }
  
  public void generateReport() {
      Connection connection = null;
      Statement stmt;
      ResultSet resultset = null;
      try {
          String selectstatement = "CALL P_Select_Salary ('2013-01-01', '2013-02-28', 1, 'Salary_Summary')";
          Class.forName("com.mysql.jdbc.Driver");
          connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/compliance?user=root&amp;password=root");
          stmt = connection.createStatement();
          resultset = stmt.executeQuery(selectstatement);
          JRResultSetDataSource resultsetdatasource = new JRResultSetDataSource(resultset);
          String realpath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("common/reports/wageslip.jasper");
          jasperprint = JasperFillManager.fillReport(realpath, new HashMap(), resultsetdatasource);
          HttpServletResponse httpservlet = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpservlet.addHeader("Content-disposition", "attachment;filename=wageslip.pdf");
          ServletOutputStream servletout = httpservlet.getOutputStream();
          JasperExportManager.exportReportToPdfStream(jasperprint, servletout);
          FacesContext.getCurrentInstance().responseComplete();
      } catch (net.sf.jasperreports.engine.JRException JRexception) {
          logger.info("JRException Exception" + JRexception.getMessage());
          JsfUtil.addErrorMessage("No Datas between FromDate and ToDate");
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          close(connection);
          close(resultset);
      }
  }
  </code></pre>