There are several ways that JasperReports can provide data to fill a report. 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 a more sophisticated custom technology to provide a table-like set of values.
iReport 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). Moreover, in iReport, you can use custom languages by registering plug-in
engines called query executors to interpret and execute the report query.
If you don’t want to use a query language, or you simply don’t want to put the query inside a report, you can use a
JasperReports data source. Basically, a JR data source is an object that iterates on a record set that is organized like a simple
table.
All the data sources implement the JRDataSource interface. JasperReports provides many ready-to-use implementations of
data sources to wrap generic data structures, like arrays or collections of JavaBeans, result sets, table models, CSV and XML
files, and so on. In this chapter I will present some of these data sources, and you will see how easy it is to create a custom data
source to fit any possible need. Finally, you will see how to define a custom query language and a custom query executor, as
well as how to use them.
iReport 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.