Pre-installed Data Source Types¶
The following data source types are pre-installed with JasperReports Server, but not visible by default in the UI:
| Name | Description |
|---|---|
|
The query data sources for different types of databases let you specify a query and return a single relational table. Thus the instance of the data source in the server contains a query that limits what data can be further queried by the report or view based on it. The The |
|
The file data sources let you specify a system file as well as a query and return a single relational table. The For information about using the file-based data sources, see the JasperReports Server Administrator Guide. |
|
These are data sources with full domain that support domain-related features like returning JDBC metadata, creating derived tables, supporting calculated fields, domain pre-filtering, joining other data sources in a virtual data source, and full support in the Domain Designer. The For information about using these data sources, see JasperReports Server Administrator Guide. |
|
These data source types are deprecated. Instead, use a JDBC data source type like Cassandra, Hive, or Impala. |
All of these data source types support the following:
-
You can use SQL queries in reports to access the data as a relational table.
-
You can create a Domain based on the data source, allowing you to alter the visibility and names of the fields extracted from the database or file. On the Display tab of the Domain Designer you can also specify which fields are measures.
-
You can create Ad Hoc views using the Domain based on the data source, allowing you to explore and interact with data from the database or file.
-
You can create virtual data sources that combine several data sources. You can then create a Domain based on the virtual data source to join the tables and access the joined data in Ad Hoc views and reports. You can even combine different formats, such as an XML file and MongoDB, as long as their data structures are compatible so the tables can be joined.
Enabling the Pre-installed Data Source Types¶
By default, the pre-installed data source types do not appear in the New Data Source dialog and must be enabled first.
To make pre-installed data source types available in the UI
- Open the file
.../WEB-INF/applicationContext-remote-services.xmlfor editing. - Locate the element
<util:set id="customDataSourcesToHide">. - Comment out the data source types you want to display.
- Restart the server.
In the following example, JSON, JSON (Before 6.4), and Remote XML data source types are commented out so they appear in the drop-down menu in the New Data Source dialog:
<util:set id="customDataSourcesToHide">
<value>remoteXmlDataSource2</value> <!-- Full domain support remote XML custom data source -->
<value>remoteXmlDataSource</value> <!-- Simple single table remote XML custom data source -->
<value>mongoDBQueryDataSource2</value> <!-- Full domain support mongodb query custom data source -->
<value>mongoDBQueryDataSource</value> <!-- Simple single table remote XML custom data source -->
<value>jsonDataSource2</value> <!-- Full domain support JSON custom data source -->
<value>jsonDataSource</value> <!-- Simple single table remote XML custom data source -->
<value>jsonQLDataSource</value> <!-- Full domain support JSON QL custom data source -->
<value>jdbcQueryDataSource2</value> <!-- Full domain support jdbc query custom data source -->
<value>jdbcQueryDataSource</value> <!-- Simple single table remote XML custom data source -->
<!--<value>xlsDataSource</value> Full domain support XLS custom data source -->
<!--<value>xlsxDataSource</value> Full domain support XLSX custom data source -->
<value>textDataSource</value> <!-- Full domain support TEXT/ CSV custom data source -->
<value>JsonSeriesDataSource</value> <!-- Simple single table remote XML custom data source -->
<value>xmlaQueryDataSource</value> <!-- Simple single table XMLA Query custom data source -->
<value>cassandraQueryDataSource</value> <!-- Deprecated. Please use cassandra SIMBA JDBC driver to run native CQL. Append "QueryMode=1" in URL in order to run CQL -->
<value>HiveDataSource</value> <!-- Deprecated. Please use Hive/ Impala JDBC drivers instead -->
</util:set>
After a data source type has been enabled in the UI, you can create an instance of that type.
To create a data source using a query example
-
Log on as an administrator.
-
Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. Alternatively, you can select Create > Data Source from the main menu on any page and specify a folder location later. If you installed the sample data, the suggested folder is Data Sources. The New Data Source page appears.
-
In the Type field, select a data source that you enabled, for example JSON Data Source (Before 6.4) or Remote XML Data Source. The fields on the page change to prompt for the connection information required for your data source.
You have the option to use attributes in the values of data source parameters. See the JasperReports Server Administrator Guide for more information.
-
Fill in the required connection information and enter the query you want to use.
-
Enter a name for the data source and an optional description. The Resource ID is generated from the name you enter. If you haven't already specified a location, expand the folder tree and select the location for your data source.
-
Click Save in the dialog. The data source appears in the repository.
Understanding the Pre-installed Data Sources¶
The Java source for the pre-installed samples can be found online:
-
Navigate to the pre-installed samples source code:
The JDBC query and flat file data source types each leverage an existing data adapter class in JasperReports Library. The data adapter class used depends on the data source type. For example, the JDBC query data source type uses a JDBCQueryDataSourceDefinition class, based on JdbcDataAdapterImpl, to allow the user to enter database connection information and a JDBC query in the New Data Source dialog. When a user creates or views a report or Ad Hoc view based on an implementation of this data source type, JasperReports Server creates a JasperReports data source as follows:
- Builds a custom data source using the JasperReports Library JDBC Data Adapter.
JDBCQueryDataSourceServicecreates a JDBC connection based on the driver, URL, username, and password entered by the user.JRJdbcQueryExecuterFactoryexecutes the user-defined query and retrieves the metadata layer necessary for Domain support.JDBCQueryDataSourceServicecreates the JasperReports data source that is used by JasperReports Library to fill the report.
In addition, the pre-installed data sources implement Domain support using the CustomDomainMetaData class.
You can find the message catalog and Spring bean definition file for each pre-installed data source type in the locations described in Table 1-1, “Files Used by a Custom Data Source Implementation,” on page 1. The file names are based on the data source name, for example:
.../WEB-INF/bundles/cassandraqueryds.properties