<

Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x

Getting Started with Jaspersoft Studio: Creating a report from a template, and Creating a datasource

Published on
11,609 Points
5,109 Views
5 Endorsements
Last Modified:
Doug Walton
DBA for the site that connects you with people and information to solve problems, inspire learning and influence the future of technology.
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:
https://community.jaspersoft.com/project/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:
  • Eclipse
  • 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:
  1. Open Eclipse
  2. Click Help
  3. Click on "Install New Software..." in the drop down menu
  4. Enter "http://jasperstudio.sourceforge.net/updates/" without quotes into the "Work with:" field
  5. 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"
  6. Click Next
  7. Accept the license agreements (after reading) and complete the installation
  8. 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:
  1. Right click on "Data Adapters" and choose "Create Data Adapter"
  2. 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.
  3. 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)"
  4. Now enter the connection string, by default it will have "jdbc:oracle:thin:@localhost:1521:database" (if you chose Oracle)
  5. Enter the username and password you want to use (note that if you save the password it will be saved in clear text)
  6. 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.
  7. Click finish to save the data adapter
Now we're ready to create our first report. To get started we'll need to:
  1. 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.
  2. Now choose a template from the list and click Next.  The "Simple Blue" template is a nice basic one to start with.
  3. Choose where to save the report and a name for the file, then click Next.
  4. 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!
  5. 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.
  6. 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.
  7. 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.


 
5
Comment
Author:Doug Walton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
0 Comments

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Join & Write a Comment

Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month