Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this questionI'm creating a JasperReports's report using some database connection using iReport. I ha开发者_运维百科ve 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?
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.
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
精彩评论