Posted by: lrrp | February 29, 2008

Open Source Java Reporting with JasperReports and iReport

asperReports, a powerful, flexible open-source reporting engine, is easy to integrate into Java enterprise applications, but it lacks an integrated visual report editor. So, if you want to use JasperReports directly, you need to manipulate its XML report structure—a relatively technical activity with a high learning curve, to say the least.

In fact, writing a full JasperReport from scratch using only the XML format is a long, painful, and unrewarding task.
Luckily, some available alternatives are much easier. The first and foremost of which is to use a visual editor to design, compile, and test your reports.

One of the most useful visual editors you can use is iReport. This article demonstrates how to use iReport to leverage the full power of JasperReports without getting entangled in complexities of the JasperReports native XML format.

Getting Started

The first thing to do is download and install iReport. It is a Java application, so you will need a JDK on your machine (JDK 1.4 or higher). This tutorial uses JDK 1.5.0:

Download iReport from ireport.sourceforge.net.
Decompress the iReport archive.
Run the startup script (bin\startup.bat or ./bin/startup.sh).

The iReport download comes with its own JasperReports package (the latest version to date, 0.5.1, supports the recently released JasperReports 1.0.1).

Figure 1. The Tutorial’s Employee Database Schema

Once you have iReport running, you can start designing your reports!

The Example Database
This tutorial uses a very simple database (see Figure 1) for demonstration. To follow along step-by-step, either download the scripts for setting up this database with MySQL and set it up on your machine, or use a similar database and translate the techniques to your situation.

Figure 2. Adding a New Database Connection

Adding a New Database Connection
First, add a new connection to your database. Use the “Datasource -> Connections/Datasources” menu to set up a new database connection (see Figure 2). If you chose the JDBC driver in the list (the example chooses MySQL), enter the server address and the database name, and then click on the ‘Wizard’ button. iReport should provide you with a correct JDBC URL for your particular database.
Now that you have a datasource, it’s time to do something with it.


Responses

  1. how ican call ireport from ibatis freamwork


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: