Java Reference
In-Depth Information
where horsepower >= 1000)
and am.aircraft_model_code = a.aircraft_model_code
and ae.aircraft_engine_code = a.aircraft_engine_code
Generating Database Reports
There are two ways to generate database reports. It can either be done by embedding
SQL queries into the JRXML report template, or by passing data from the database to
the compiled report via a datasource. We will discuss both of these techniques.
We will first create the report by embedding the query into the JRXML template.
We will then generate the same report by passing it a datasource containing the
database data.
Embedding SQL Queries into a Report
Template
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"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="DbReport">
<queryString>
<![CDATA[select a.tail_num,
a.aircraft_serial,
am.model as aircraft_model,
ae.model as engine_model
from aircraft a,
aircraft_models am,
aircraft_engines ae
where a.aircraft_engine_code in ( select
aircraft_engine_code
from aircraft_engines
where horsepower >= 1000)
and am.aircraft_model_code = a.aircraft_model_code
and ae.aircraft_engine_code = a.aircraft_engine_code]]>
</queryString>
<field name="tail_num" class="java.lang.String"/>
<field name="aircraft_serial" class="java.lang.String"/>
<field name="aircraft_model" class="java.lang.String"/>
<field name="engine_model" class="java.lang.String"/>
 
Search WWH ::




Custom Search