Data Sources

JasperReports can fill a report with data in a number of ways. For example, you can put an SQL query directly inside a report and provide a connection to a database against which to execute the query and read the resulting record set, or you can use more sophisticated custom technology to provide a table-like set of values.

Jaspersoft Studio provides direct support for a rich set of query languages, including SQL, HQL, EJBQL, and MDX, and supports other languages like XPath (XML Path Language). If you don’t want to use a query language or put your query inside your report, you can use a JasperReports data adapter. Basically, a JasperReports data adapter is an object that iterates on a record set that is organized like a simple table.

All the data adapters implement the JRDataSource interface. JasperReports provides many ready-to-use implementations of data sources to wrap generic data structures, such as arrays or collections of JavaBeans, result sets, table models, CSV and XML files. This chapter documents some of these data sources.

Jaspersoft Studio provides support for all these things: you can define JDBC (Java Database Connectivity) connections to execute SQL queries, set up Hibernate connections using Spring, and test your own JRDataSource or your custom query language.

This chapter has the following sections:

Data Adapters
Creating and Using Database JDBC Connections
Working with Your JDBC Connection
Understanding the JRDataSource Interface
Data Source Types
Importing and Exporting Data Sources
A Look at TIBCO Spotfire Information Links