JDBC Data Source and SQL Queries
Harry
· 24 Sep 2026
· 1 views
Log in to track your progress and mark lessons complete.
Sponsored
Query-Based Reports
Instead of beans, embed SQL directly: in Jaspersoft Studio create a Data Adapter → JDBC, then write the query in the Dataset dialog. Fields are derived from the result-set columns.
<queryString>
<![CDATA[SELECT name, salary FROM employees WHERE dept = $P{dept}]]>
</queryString>Filling from a Connection
try (Connection con = dataSource.getConnection()) {
JasperPrint print = JasperFillManager.fillReport(report, params, con);
}Use $P!{...} syntax when a parameter must be spliced into SQL (e.g. an ORDER BY column) rather than bound.