
Example 1: Adding a general HDS
JReport Designer provides you with a set of hierarchical data source APIs that allow you to import a customized hierarchical data source.
Compiling the source files
There are three classes used in this example. Their source code files are HierarchicalDataSource.java, HierarchicalDatasetMetaData.java, and HierarchicalDataset.java, which are available in <install_root>\help\samples\APIUDS\hierarchicalUDS. In this example, the HierarchicalDataSource.java will return the result set from the demo HSQL DB.
- Copy the above three files to 
<install_root>\help. Modify the demo HSQL DB path in both HierarchicalDatasetMetaData.java and HierarchicalDataset.java. 
- Compile the Java files to generate HierarchicalDataSource.class, HierarchicalDatasetMetaData.class, and HierarchicalDataset.class.
 
- Append the path 
<install_root>\help to the class path of JReport.bat in <install_root>\bin which starts JReport Designer, so that at runtime HierarchicalDataSource can be found. 
Adding the HDS to a catalog
After compilation, you can now add the HDS to a JReport catalog.
- Start JReport Designer with the batch file you just modified and open an existing catalog.
 
- In the Data tab of the Catalog Browser, expand the data source to which to add the HDS, then right-click the Hierarchical node, and then select Add General Hierarchical Data Source from the shortcut menu. The Add General Hierarchical Data Source dialog appears. See the dialog.
 
- Click the Browse button to find the class HierarchicalDataSource.class.
 
- Type a number in the Parameter box. Then, only the records whose employee ID is less than this number will be fetched.
 
- Click Load Tree. The data source tree will then be parsed.
 
- Modify the column properties in the Columns box as required.
 
- Click OK to add the HDS.
 
 