使用JasperReport+iReport生成报表出现一个问题,请各位高手帮忙看一下!急!
将日期参数传入SQL中查询,结果不能生成报表。报表参数已加入:startDatejava.util.DateendDatejava.util.Date字段中已加入:col...
将日期参数传入SQL中查询,结果不能生成报表。
报表参数已加入:startDate java.util.Date
endDate java.util.Date
字段中已加入: collectDate java.util.Date
报错如下:
net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query :
select a.personName,b.deviceRecordID,c.merchantName, b.sign,b.collectContent from person a,deviceRecord b,merchant c where a.personID = b.personID and c.merchantID = b.merchantID and b.collectDate between '?' and '?' at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:192) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:123) at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:656) at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:588) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1212) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:849) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:798) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:947) at java.lang.Thread.run(Thread.java:595) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.validateParameterIndex(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setDate(Unknown Source) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:396) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:209) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:184) ... 11 more
Print was not filled. Try using an EmptyDataSource...
我现在把SQL语句修改了一下,
between '?' and '?' 修改为:between ? and ? 将现在报表没问题了。
日期格式定义不变 展开
报表参数已加入:startDate java.util.Date
endDate java.util.Date
字段中已加入: collectDate java.util.Date
报错如下:
net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query :
select a.personName,b.deviceRecordID,c.merchantName, b.sign,b.collectContent from person a,deviceRecord b,merchant c where a.personID = b.personID and c.merchantID = b.merchantID and b.collectDate between '?' and '?' at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:192) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:123) at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:656) at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:588) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1212) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:849) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:798) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:947) at java.lang.Thread.run(Thread.java:595) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.validateParameterIndex(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setDate(Unknown Source) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:396) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:209) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:184) ... 11 more
Print was not filled. Try using an EmptyDataSource...
我现在把SQL语句修改了一下,
between '?' and '?' 修改为:between ? and ? 将现在报表没问题了。
日期格式定义不变 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询