Browse All Articles
> Getting Started with Jaspersoft Studio: Creating a report from a template, and Creating a datasource
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource. In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource (usually a database connection).
Here's their website with further information about Jaspersoft Studio:
In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Before we get started you'll need a couple things:
- Jaspersoft Studio Eclipse Plugin
- A database (I'll be using Oracle as an example, but it supports any JDBC connection)
You can download and install Eclipse by following the instructions here: https://www.eclipse.org/users/
To install the Jaspersoft Studio plugin you'll need to follow these steps:
- Open Eclipse
- Click Help
- Click on "Install New Software..." in the drop down menu
- Enter "http://jasperstudio.sourceforge.net/updates/" without quotes into the "Work with:" field
- Select the main checkbox for "Business Intelligence, Reporting Tools" which should check all the checkboxes for that category
The current version of Jaspersoft Studio is "5.6.2.final"
- Click Next
- Accept the license agreements (after reading) and complete the installation
- Eclipse will need to restart
Once Eclipse restarts you should be able to start using Jaspersoft Studio. To get the perspective open you'll need to click on the "Open Perspective" button near the top right and find the "Report Design" option (it's a red square with a couple white lines that look like a mountain or a line graph).
Now that we have the Report Design perspective we can create our datasource. There should be two tabs in the top left pane called "Repository Explorer" and "Project Explorer." First, select the "Repository Explorer" tab and then:
- Right click on "Data Adapters" and choose "Create Data Adapter"
- A window will popup, for connecting to a database select "Database JDBC Connection" and click next.
All the options in that list are available data adapters, but for the purposes of this article we're only creating a database connection.
- Name the data adapter and choose what driver you want to use. I'm using Oracle so I need to choose "Oracle (oracle.jdbc.driver.OracleDriver)"
- Now enter the connection string, by default it will have "jdbc:oracle:thin:@localhost:1521:database" (if you chose Oracle)
- Enter the username and password you want to use (note that if you save the password it will be saved in clear text)
- Click "Test" to make sure your connection works. If it doesn't you might have entered the connection or user info incorrectly. If it's correct then make sure you can connect to your database from the machine you are running eclipse from.
- Click finish to save the data adapter
Now we're ready to create our first report. To get started we'll need to:
- Click File, New, "Jasper Report"
If that option doesn't show up, click "Other," scroll down the list to the folder called "Jaspersoft Studio," choose "Jasper Report" and click Next.
- Now choose a template from the list and click Next. The "Simple Blue" template is a nice basic one to start with.
- Choose where to save the report and a name for the file, then click Next.
- If you have a database query ready choose your data adapter from the drop down list and enter your query, then click Next. If you don't have a query you can also do this later, just click Next and you're done!
- If you entered a query now you have to option to auto create fields (each column of the query is called a field Jasper). Choose the fields you want the report to use and click the ">" button to select them, or click ">>" to select them all. Click Next to continue.
- If you want to group your data by any of the fields you can select them the same way here. This is mostly useful if you plan on doing calculations on groups of data (for example, doing a distinct count on customers for each day). If you aren't sure if you need a group you can always do this later by right clicking on the report.
- After clicking Next it brings you to the last page saying "Congratulations!" You can either go back to make changes, or click Finish to create your report.
If you filled out the query and chose fields (steps 4-6 above) the default report will come up with your fields filled in as columns with the field names set as the headers for each column. In most cases for simple reports this is all you need to do. You can click preview near the bottom of the report and it will connect to the database and populate the fields.
After you get more familiar with the software I'd recommend doing some research on using groups, parameters, and variables.