Unknown column name issue [closed]

空扰寡人 提交于 2020-01-05 08:38:14

问题


I'm creating a JasperReports's report using some database connection using iReport. I have added a new field to the report. That field does not exist in the database column. I have put that column in the report and assigning the value to this field using the expression.

It compiles fine but when I fill the report using the database, it gives me the error:

Error filling print... Unknown column name : test 
net.sf.jasperreports.engine.JRException: Unknown column name : test
at net.sf.jasperreports.engine.JRResultSetDataSource.getColumnIndex(JRResultSetDataSource.java:355) 
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:112)  
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:823)  
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:787)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1474)  
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:125) 
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:938)  
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841)  
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)  
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)  
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)  
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:858)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)  
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)  
Print not filled. Try to use an EmptyDataSource...

How can I use the user defined fields in JasperReports?


回答1:


I'm not sure of what causes you this error stack but I think it's because you have a field in your SELECT which does not match any field in your report Fields.
My advice is to use "Read Field" button in Report query window, it fill Fields variables with the fields of the query and avoid later problems.




回答2:


One cause might be the length of the field $F{name}. The name shouldn't exceed 32 characters (field < 32).

I also have had this exception, but after renaming the fields everything works fine.

Kind regards, Serge



来源:https://stackoverflow.com/questions/3976458/unknown-column-name-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!