An SQL query is the most common way to fill a report. Jaspersoft Studio provides several tools for working with SQL, including a query designer and a way to automatically retrieve and register the fields derived from a query in the report.
Before opening the query dialog, be sure you select the correct connection/data source. All operations performed by the tools in the query dialog use this data source.
To open the query dialog (“Query Dialog”) right-click the name of your report in the Outline view and choose Dataset and Query....
![query-dialog.png.698687024c2f4c4d8dd3f271aa11920a.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
Query Dialog |
Jaspersoft Studio doesn't require a query to generate a report. It can obtain data from a data source that is not defined by a query execution. JasperReports supports multiple query languages including:
If the selected data source is a JDBC connection, Jaspersoft Studio tests the access connection to the data source as you define the query. This allows Jaspersoft Studio to identify the fields using the query metadata in the result set. The design tool lists the discovered fields in the bottom portion of the window. For each field, Jaspersoft Studio determines the name and Java type specified by the JDBC driver.
If your query accesses tables containing large amounts of data, scanning the data source for field names could take a while. In this case you might consider disabling the Automatically Retrieve Fields option to quickly finish your query definition. When you've completed the query, click the Read Fields button to start the fields discovery scan.
![note-icon-ns_28x28.png.5be1f85371279d00dd1ca4189b8818ac.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) | All fields used in a query must have a unique name. Use alias field names in the query for fields having the same name. |
The field name scan may return a large number of field names if you are working with complex tables. To reduce unnecessary complexity, we suggest that you review the list of discovered names and remove fields you're not using in your report.When you click OK all the fields in the list are included in the report design. Although you can remove them later in the outline view, it’s a good idea at this point in the design process to remove any field names that you won’t be using.
Recommended Comments
There are no comments to display.