title: Passing an entire sql query as a parameter in jasper reports
body: <p>I want to pass an entire sql query as a parameter into a jasper report. I tried using $P{QUERY}, but it gave me a mysql syntax error exception. And I want it to be passed during run time. Does anyone know how to do it?</p>
  
  <p>Example code:</p>
  
  <pre><code>try {
          Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
          Connection conn = DatabaseConnection.getInstance().getConnection();
  
          map.put("QUERY", "Select u.name, u.status from user_info u where u.user_name = 'Thanuj'");
  
          JasperReport report = JasperCompileManager.compileReport("report1.jrxml");
          JasperPrint jp = JasperFillManager.fillReport(report, map, conn);
          JasperViewer.viewReport(jp, false);
      } catch (JRException ex) {
          Logger.getLogger(ReportTest.class.getName()).log(Level.SEVERE, null, ex);
      } catch (SQLException ex) {
          Logger.getLogger(ReportTest.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ClassNotFoundException ex) {
          Logger.getLogger(ReportTest.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>