There are two ways to generate database reports—either by embedding SQL queries into the JRXML report template or by passing data from the database to the compiled report through a datasource. We will discuss both of these techniques.
We will first create the report by embedding the query into the JRXML template. Then, we will generate the same report by passing it through a datasource containing the database data.
JasperReports allows us to embed database queries into a report template. This can be achieved by using the
<queryString> element of the JRXML file. The following example demonstrates this technique:
<?xml version="1.0" encoding="UTF-8" ?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ...