title: How to pass parameters to JasperReport with java to use later in SQL query
body: <p>I already have 6 Jasper Report templates created, with all of the static text fields to be filled out using a SQL query. The SQL query uses 2 parameters that I am passing in: <strong>FirstName</strong> and <strong>LastName</strong>. I am also passing in 2 other parameters that will just get added to Report.</p>
  
  <p>This is the code i have so far to pass the HashMap with the parameters to the Report. But I am lost as there isnt really any good documentation or examples that I can find.</p>
  
  <pre><code>package print;
  import net.sf.jasperreports.engine.*;
  import net.sf.jasperreports.engine.export.*;
  import java.util.*;
  
  public class PrintCertificate  
  {   
     public PrintCertificate(String output, String certType, String firstName, String lastName, String confirmDate, String pastorName)
     {
      if(certType=="rci_eng")
      {
          String fileName = "/RCI_Eng.jasper";
          output = "C:/Users/User/Desktop/Test/";
  
          HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
          map.put("FirstName",firstName);
          map.put("LastName",lastName);
          map.put("PastorName", pastorName);
          map.put("DateOfConfirmation", confirmDate);
          try
          {
              JasperPrint print = JasperFillManager.fillReport(fileName, map);
              JRDocxExporter exporter = new JRDocxExporter();
              exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
              exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "test.docx");
              exporter.exportReport(print);
  
          }
          catch (Exception e)
          {
              e.printStackTrace();
              System.exit(1);
          }
      }
    }
  }
  </code></pre>
  
  <p>I know this is probably far from correct, but if someone can point me in the right direction of good documentation or examples, or point out what I've done wrong, it would be of great help!</p>