
Cached query results
By default, when you run a report, JReport Engine fetches data from the database using the JDBC driver. For reports that are built on queries (and imported SQL files, stored procedures and UDSs which function as queries), JReport Designer enables you to create cached result files and save them somewhere in your machine. Then, when you view these reports, you can choose to use the data from the cached query result file as opposed to the database. This is very useful for working on the design of a report while you are off-line and do not have a DBMS connection. Additionally, it is helpful when you need to send data and reports to Jinfonet Support for assistance.
Creating a cached query result
JReport Designer provides you with two ways to create cached query results, the first is with the Catalog Browser panel and the second is with the Resource View panel.
- To create a cached query result file in the Catalog Browser panel:
- In the Data tab of the Catalog Browser, select the data object for which you intend to create the cached query result file.
- Right-click the data object, and select Create Cached Query Result from the shortcut menu.
- In the Save Cached Query Result dialog, specify the file name with or without an extension and the folder to where you want to save the result file.
- Click OK and the cached query result file will be saved to the specified folder.
- To create a cached query result file in the Resource View panel:
- Open a report, in the Resource View panel, right-click the query on which the report is built and select Create Cached Query Result from the shortcut menu.
- In the Save Cached Query Result dialog, specify the file name with or without an extension and the folder to where you want to save the result file and then click OK.
Using a cached query result to run a report
To run a report on a cached query result, follow the steps below:
- Open a report, in the Report Inspector, select the node that represents the dataset used by the report and specify its Data Driver property in the Properties panel as follows:
jrquery:/jet.universe.resultfile.UResultFileResultSet;Full path of the cached query result
For example, if the cached query result has been saved to C:\JReport\Designer\Cached
with the file name test, the property value should be jrquery:/jet.universe.resultfile.UResultFileResultSet;C:\JReport\Designer\Cached\test
- Click the View tab to view the report. You will now see that the report data has been retrieved from the cached query result file.
Note: If you check the option Use cached query result in the Catalog category of the Options dialog, whenever you view a report, a dialog will prompt you to choose a cached query result to run the report.
Managing cached query results
You may find it inconvenient to input a property value that is long and complicated. To help you with this, JReport Designer provides a tool for managing your cached query results, the Data Source Driver Manager.
Assume that a cached query result file orderstat_cached for the query OrderStat in the catalog file SampleReports.cat has been created and saved in C:\JReport\Designer\Cached
. To use the Data Source Driver Manager, follow the steps below:
- Click File > Catalog Management > Open Catalog in JReport Designer.
- In the Open Catalog File dialog, select to open the catalog file SampleReports.cat.
- In the Catalog Browser, click the Data Source Driver Manager button
on the toolbar to open the Data Source Driver Manager dialog. See the dialog.
- Click the Add button, and the Data Source Editor dialog appears. See the dialog.
- Input a name for the driver in the Driver Name box. Here, we name it OrderStat.
- Check the URL radio button and input the URL as follows:
jrquery:/jet.universe.resultfile.UResultFileResultSet;Full path of the cached query result
In the example, the URL is jrquery:/jet.universe.resultfile.UResultFileResultSet;C:\JReport\Designer\Cached\orderstat_cached
Note: If you check the Driver radio button to specify the driver, you will need to input the class name and parameter of the driver as follows:
- Class Name: jet.universe.resultfile.UResultFileResultSet
- Parameter: Full path of the cached query result (
C:\JReport\Designer\Cached\orderstat_cached
in this example)
Then, a URL will be generated according to your input information.
- Click OK to add the driver to the Data Source Driver Manager.
- Repeat the above steps to add more drivers to the manager.
- In the Data Source Driver Manager dialog, all the added drivers will be listed in the Data Source Driver Manager box. If you want to remove a driver, select the driver and click the Remove button. To edit a driver, select the driver and click the Edit button.
- Click OK to close the dialog.
Upon running a report using a cached query result, you can choose an appropriate driver from the Data Driver property's drop-down list directly without inputting the long value manually.
