使用日期参数时出错

时间:2013-02-18 18:32:39

标签: jasper-reports ireport

我正在使用iReport 5.0.1。我创建了一个日期参数,并在我的查询中使用它:

enter image description here

当我预览报告时,我输入了我的日期参数:

enter image description here

输入所有参数并运行报告后,我收到此错误:

Error filling print... Error executing SQL statement for : Sample
net.sf.jasperreports.engine.JRException: Error executing SQL statement for : Sample 
    at com.jaspersoft.jrx.query.PlSqlQueryExecuter.createDatasource(PlSqlQueryExecuter.java:143) 
    at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1086) 
    at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:667)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1258) 
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877) 
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822) 
    at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61) 
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446) 
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276) 
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745) 
    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: org.postgresql.util.PSQLException: ERROR: syntax error at or near "Feb" 
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592) 
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327) 
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192) 
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451) 
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350) 
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254) 
    at com.jaspersoft.jrx.query.PlSqlQueryExecuter.createDatasource(PlSqlQueryExecuter.java:136) 
    ... 12 more 
Print not filled. Try to use an EmptyDataSource...

这里发生了什么,我该如何解决这个问题?谢谢!

1 个答案:

答案 0 :(得分:0)

我认为!中的$P!{...}表示在报告中包含参数的文字值。

尝试使用$P{start_date}$P{end_date},两者都没有!

实际上,您的SQL语句正在使用:

and finalinsdate >= Feb/18/2013

这不是一个有效的SQL语句,这意味着PostgreSQL会抱怨:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "Feb"

下次复制并粘贴源代码,而不是进行屏幕截图。