Hello! I'm using JasperReports engine, and one of the reports gets data from database executing SQL statement.
Is there a way to pass parameters to that query?
Thanks in advance!
views:
153answers:
1
+1
A:
First, create a new parameter in your report. Then insert the parameter in your query, for example:
select name, department from employees where employee_id = $P{employeeId}
Make sure your parameter types matches the data type of the columns in your database. Finally, simply pass your parameters to the JasperReports engine. An example would be:
parameters.put("employeeId", Long.valueOf(14309));
JasperRunManager.runReportToPdf(reportFile,parameters,con);
gedim
2010-09-17 08:59:30
Thanks! That works fine for me!
Andrew
2010-09-17 09:03:21