Example 1: Importing from a database

In the sample program ParamTest.java, different values were assigned to the parameter p_StartDate by accessing values from an HSQL database. In addition, the sample report set CustomerAnalysis.cls uses this parameter in the query condition. So here, we use this demo report set as an example to explain how to import parameter values from a database, so that you do not need to type in the values one by one while specifying the parameter default value (note that in this example we assume your JReport Designer is installed in the default path, that is C:\JReport\Designer).

  1. Compile ParamTest.java to generate ParamTest.class, and store the class file in C:\JReport\Designer\help.

    javac -classpath c:\jreport\designer\lib\JREngine.jar; ParamTest.java
  2. Append C:\JReport\Desginer\help to the classpath variable of JReport.bat in C:\JReport\designer\bin.
  3. Start JReport Designer with the modified batch file.
  4. Open CustomerAnalysis.cls.
  5. In the Report Inspector, find the report set property Import Parameter Values (this property is a report set level property, so you have to make the report set node show in Inspector. To show it, select the CustomerAnalysis node, and then click the Up button on the Inspector toolbar), and input the class name with the full package name. In this example, input help.ParamTest, and then set the property Parameter List Auto to false.
  6. Save the report set and catalog, and then view the report result.
  7. In the Enter Parameter Values dialog, click the drop-down list of the parameter. You will find that all the values you specified in ParamTest.java have been imported into the list.
  8. Select one of the values with which to view the report.
  9. Publish the saved report set CustomerAnalysis.cls to JReport Enterprise Server (for details, see Publishing resources remotely).
  10. Append C:\JReport\Designer to the classpath variable of JREntServer.bat in <server_install_root>\bin.
  11. Start JReport Enterprise Server with the modified batch file.
  12. Load your web browser to access the JReport Enterprise Server Console Page. You will then have the same parameter values as you did in JReport Designer.

Note: In the sample ParamTest.java, we used the method compareToIgnoreCase( ) to compare the parameter name in the class file with the one in your report. This method is not case sensitive when performing the comparison.