Data Adapters

A data adapter is a resource that specifies how and where to obtain data. Specifically, it is an object that contains information about how to connect to or retrieve the data, and the logic to do that. Data adapters are stored in XML files and simplify porting of the report configuration and data source creation between JasperReports environments. Whether you use a report with a data adapter XML file in Jaspersoft Studio, publish it to JasperReports Server or deploy it to a custom JasperReports environment, JasperReports Library can use it to obtain the data you specify.

This chapter starts by telling you how to create and use data adapters based on the data adapter types available in Jaspersoft Studio. Data adapters are designed to simplify the complexities of working with data in JasperReports Library. However, data adapters are only one of the ways that JasperReports Library can get data from a data source. As you get more familiar with Jaspersoft Studio, you may want to go a little deeper and learn about data in JasperReports Library and the JRDataSource interface.

Usually data adapters are stored as XML files in the same project as the report to simplify deployment to JasperReports Server or another environment. In Jaspersoft Studio, data adapters can also be stored in the Repository Explorer, in which case they are visible from all the projects. If you plan to deploy the report outside Jaspersoft Studio, it is better to store it in the project from the beginning.

This chapter has the following sections:

Creating and Editing Data Adapters
Using Data Adapters in Reports and Datasets
Working with Database JDBC Connections
Working with a MongoDB Data Adapter
Working with a Google BigQuery Data Adapter
Working with a Collection of JavaBeans Data Adapter
Working with XML Data Adapters
Working with XML/A Data Adapters
Working with CSV Data Adapters
Using the Empty Record Data Adapter
Using the Random Data Adapter
Working with the JRDataSource Interface
A Look at TIBCO Spotfire Information Links