[英]How to register a QueryExecuterFactory in jasper reports in java
I implemented JRQueryExecuter and want to use it in a report.我实现了 JRQueryExecuter 并想在报告中使用它。 Using iReport I managed to register and use the executer.
使用 iReport 我设法注册并使用了执行器。
Now I want to use it in a java application, but I can't find any resources how to register the factory.现在我想在java应用程序中使用它,但是我找不到任何资源如何注册工厂。
I thought it's enough to have the implementation in the classpath, but I get the following exception:我认为在类路径中实现就足够了,但是我得到了以下异常:
Caused by: net.sf.jasperreports.engine.JRException: No query executer factory class registered for tmql queries.
at net.sf.jasperreports.engine.query.DefaultQueryExecuterFactoryBundle.getQueryExecuterFactory(DefaultQueryExecuterFactoryBundle.java:80)
at net.sf.jasperreports.engine.util.JRQueryExecuterUtils.getQueryExecuterFactory(JRQueryExecuterUtils.java:57)
at net.sf.jasperreports.engine.design.JRDesignDataset.queryLanguageChanged(JRDesignDataset.java:1006)
Can anybody give me a hint?任何人都可以给我一个提示吗?
regards Hannes关于汉内斯
Using jasperreports 5.2.0, you need to:使用 jasperreports 5.2.0,您需要:
YourCustomExecuterFactory
implementing QueryExecuterFactory
class.YourCustomExecuterFactory
实现QueryExecuterFactory
类。YourCustomExecuterFactory
use your custom JRQueryExecuter
implementing method QueryExecuterFactory.createQueryExecuter(..)
YourCustomExecuterFactory
使用您的自定义JRQueryExecuter
实现方法QueryExecuterFactory.createQueryExecuter(..)
jasperresports.properties
set this property: net.sf.jasperreports.query.executer.factory.tmql=your.package.YourCustomExecuterFactory
jasperresports.properties
中设置此属性: net.sf.jasperreports.query.executer.factory.tmql=your.package.YourCustomExecuterFactory
Hope this helps to somebody.希望这对某人有所帮助。
The documentation suggests to set a property:该文档建议设置一个属性:
JasperReport jasperReport = <...>
jasperReport.setProperty(JRQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX + "<query language>", "<value>");
Does that work?那样有用吗?
Set the property before calling JasperCompileManager.在调用 JasperCompileManager 之前设置属性。
Example below using plsql query language:下面使用 plsql 查询语言的示例:
JRProperties.setProperty(QueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX+"plsql"
,"com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");
JasperReport jasperReport =
JasperCompileManager.compileReport(sourceFile);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.