Chapter 4. Creating Dynamic Reports from Databases
In the previous chapter, we learned how to create our first report. The simple report in the previous chapter contained no dynamic data. In this chapter, we will explore how to create a report from the data obtained from a database.
In this chapter, we will cover the following topics:
How to embed SQL queries into a report template
How to pass rows returned by an SQL query to a report through a datasource
How to use report fields to display data obtained from a database
How to display database data in a report by using the
<textField>
element of the JRXML template
Note
Datasource definition
A datasource is what JasperReports uses to obtain data for generating a report. Data can be obtained from databases, XML files, arrays of objects, collections of objects, and XML files.
In this chapter, we will focus on using databases as a datasource. The next chapter discusses the other types of datasources.