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 data obtained from a database.
In this chapter, we will cover the following topics:
- How to embed SQL queries into a report definition
- How to pass rows returned by an SQL query to a report via a datasource
- How to use report fields to display data obtained from a database in a report
- How to display data from a database in a report by using the
<textField>
element of the JRXML templateTip
Datasources: Definition
A datasource is what JasperReports uses to obtain data to generate a report. Data can be obtained from databases, XML files, arrays of objects, collections of objects, and XML files.
This chapter focuses on using databases as a datasource. The next chapter discusses other types of datasources.