title: Error executing sql statement when using java expression in ireport
body: <p>I'm using iReport for my report development. </p>
  
  <p>I have 2 parameters which is the 1st parameter (companyName) is embedded into 2nd parameter(pCompanyName). I'm also filtering the parameter using 2 options. If the parameter is null, it will print out "" or blank, else it will print the query. Please refer to parameter section below. When using groovy language, it will print out the report.</p>
  
  <p>The problem is after change the language from groovy to java expression the report print out the error. Below is the error. Someone here please help.. Desperate. </p>
  
  <blockquote>
    <p>Error filling print... Error executing SQL statement for : laporan_quota
    net.sf.jasperreports.engine.JRException: Error executing SQL statement for : laporan_quota
        at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:240)
        at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1114)
        at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:691)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1314)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:931)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:873)
        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87)
        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:287)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:760)
        at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
    Caused by: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)     at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)     at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)     at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)     at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)     at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
        at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)
        at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:774)
        at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:925)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1111)
        at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4798)
        at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4845)
        at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1501)
        at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:233)</p>
  </blockquote>
  
  <p><strong>Sql</strong></p>
  
  <pre><code>SELECT DISTINCT
  b.company_name company_name,
  a.app_id permit_id,
  b.quota_year,
  b.app_id app_id,
  g.descr ap_category,
  h.descr ap_subcategory,
  a.tariff_code hs_code,
  h.descr model,
  a.product_desc goods_description,
  a.quantity quantity,
  a.price_tot total_cost,
  a.permit_no permit_no,
  a.license_id license_no,
  a.approved_date approve_date,
  a.origin_country origin_country,
  a.cnor_addr3 consignor_country,
  a.branch_id miti_branch,
  c.descr permit_status,
  a.port_discharge port_name,
  a.effect_date effective_date,
  a.expiry_date expiry_date
  FROM PERMIT_APP a, MT_PERMIT_APP_MASTER b, MT_REF_PERMIT_STATUS c, MT_QUOTA d, MT_QUOTA_APP e, MT_AP_TYPE f, MT_AP_CATEGORY g,
  MT_AP_SUBCATEGORY h, MT_AP_TYPE_OPTION i
  WHERE
  a.master_app_id = b.app_id
  AND b.quota_id = d.quota_id
  AND d.quota_id = e.quota_id
  AND f.ap_type_code = g.ap_type_code
  AND g.ap_category_code = h.ap_category_code
  AND h.ap_subcategory_code = b.ap_subcategory_code
  AND f.ap_type_code = i.ap_type_code
  AND a.status_code = c.status_code
  AND c.status_code in ('102','301')
  AND i.option_type = 'QUOTA'
  $P!{pCompanyName}
  </code></pre>
  
  <p><strong>Parameters</strong> </p>
  
  <p>1) $P{companyName}  </p>
  
  <p>2) $P!{pCompanyName} </p>
  
  <pre><code>($P{companyName}.isEmpty() ? "" : " AND b.company_name = 'JA' ")
  </code></pre>