Data sources belong to the report engine, JasperReports Server, and are not defined in the main JRXML. The JRXML does not retain any data source defined in iReport when you add the JRXML to the server. You need to define a data source in the server that the report unit can use. From the Data Source page, select a data source in the repository or create a new data source on-the-fly. The data source can be different from the database configured for JasperReports Server if the application server can find its driver. For example, in a default installation of JasperReports Server, Tomcat looks for data source drivers in <js‑install>/apache-tomcat/lib. Put a copy of the driver in this location.
To define the data source for the simple report example:
|
1.
|
In the JasperReport wizard, click Data Source. |
The Link a Data Source to the Report page presents these choices:
|
•
|
Do not link a data source – Select or define the data source at a later time. You see an error if you run the report in this state. |
|
•
|
Click here to create a new data source – Define a new data source that is only available to your report. |
|
•
|
Select data source from repository – Select an existing data source from the repository. |
|
2.
|
Choose Select data source from the Repository and Browse to /Data Sources/JServer JNDI Data Source. Click Select. The path to the data source appears. |
|
3.
|
Click Query to define the Query as described in the next section. |