简体   繁体   中英

How to register a QueryExecuterFactory in jasper reports in java

I implemented JRQueryExecuter and want to use it in a report. Using iReport I managed to register and use the executer.

Now I want to use it in a java application, but I can't find any resources how to register the factory.

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:

  1. Create a custom YourCustomExecuterFactory implementing QueryExecuterFactory class.
  2. Make your new YourCustomExecuterFactory use your custom JRQueryExecuter implementing method QueryExecuterFactory.createQueryExecuter(..)
  3. Map the new language (tmql?) to your custom factory. In your jasperresports.properties set this property: 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.

Example below using plsql query language:

JRProperties.setProperty(QueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX+"plsql"
                            ,"com.jaspersoft.jrx.query.PlSqlQueryExecuterFactory");
JasperReport jasperReport =
            JasperCompileManager.compileReport(sourceFile);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM