Reputation: 97
I'm new to Jasper Reports.I was able to generate a report successfully with SQL query embedded inside the jrxml file. (I'm using JasperStudio plugin for eclipse)
But now I want to use my bean class as a datasource. Need some help in getting started -
Requirement : User-enters values in the Donation Receipt form on screen. Persist DonationReceipt bean in the database and generate a Donation receipt pdf with the bean values.
1. Created a new Data Adapter of "Collection of JavaBeans" type -
Upvotes: 0
Views: 978
Reputation: 2239
We achieved it using the code similar to the snippet below.
public static Collection<DonationReceipt> createBeanCollection(){
List<DonationReceipt> dataList = new ArrayList<DonationReceipt>();
String sqlQuery = '<your select SQL>';
...
ResultSet rs = ..
while(rs.next()){
DonationReceipt dr = new DonationReceipt();
dr.setReceiptNo(rs.getString(..));
...
dataList.add(dr);
}
return dataList;
Upvotes: 1