Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Friday, July 22, 2011

JasperReports and Data Sources

JasperReports are very portable.  Create reports in iReport Designer and publish the JRXML to JasperReports Server.

It's easy to move a JasperReport around because the Data Sources are completely separated from the reports themselves.  In both iReport Designer and JasperReports Server, the linkage between a report and its Data Source is established in a separate step from the creating and the running of the report.

In iReport Designer, the Data Source is setup in the top of the screen.  This Data Source "OEREPORTDEV" has read-only access to all of the tables in an OpenERP installation.  In this case, JasperReports Server is deployed on PostgreSQL.  OEREPORTDEV uses login role (username in other dbs) 'myuser' that is a member of the 'oereport' group role.

iReport with Data Source Control Highlighted
To the left of the screen is the Repository Navigator.  This is hooked up to a JasperReports Server and is retrieving a list of  reports that have been deployed.  "PartnersReport" was uploaded.

On the JasperReports Server (v4.1.0), the report "Partners Report" is shown.  This report's JRXML was uploaded from iReport Designer.  Various attributes -- most notably the Data Source -- can be set on the server.

Reports Uploaded to Server Repository

The Data Source screen configures connections, usernames, passwords, and drivers.  The Data Source OEREPORTDEV uses a login role 'oereport_ds' which is a member of the 'oereport' group role as was the 'myuser' used on iReport Designer.  It's a good practice to separate these so that the shared server account isn't locked out or has its password changed.

JasperReports Server Data Sources

Access and configuration of Data Sources is a big benefit to using JasperReports Server over a custom web application.  Although the custom web application can make JR library calls to compile and fill a JRXML file, the server has a much cleaner workflow since you'll have to come up with your own data source management (Tomcat, Spring, etc.).

No comments:

Post a Comment