iReport in NetBeans

Exclusive offer: get 50% off this eBook here
iReport 3.7

iReport 3.7 — Save 50%

Learn how to use iReport to create, design, format, and export reports

$23.99    $12.00
by Shamsuddin Ahammad | March 2010 | Java Open Source

NetBeans is a free, opensource Integrated Development Environment(IDE) for software developers. This IDE provides many good tools that are required to create professional, desktop, enterprise, web, and mobile applications using the Java language. We can also create reports in NetBeans, if the iReport plugin is installed. So far, we have created different types of reports with the iReport standalone version. In this article by Shamsuddin Ahammad, author of iReport 3.7, we will learn about:

  • Installing the iReport plugins in NetBeans
  • Creating different types of reports inside the NetBeans IDE

Creating different types of reports inside the NetBeans IDE

The first step is to download the NetBeans IDE and the iReport plugin for this. The iReport plugin for NetBeans is available for free download at the following locations: https://sourceforge.net/projects/ireport/files or http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=4425

After downloading the plugin, follow the listed steps to install the plugin in NetBeans:

  1. Start the NetBeans IDE.
  2. Go to Tools | Plugins.
  3. Select the Downloaded tab.
  4. Press Add Plugins….
  5. iReport 3.7

  6. Select the plugin files. For iReport 3.7.0 the plugins are: iReport-3.7.0.nbm, jasperreports-components-plugin-3.7.0.nbm, jasperreportsextensions-plugin-3.7.0.nbm, and jasperserver-plugin-3.7.0.nbm. After opening the plugin files you will see the following screen:
  7. iReport 3.7

  8. Check the Install checkbox of ireport-designer, and press the Install button at the bottom of the window. The following screen will appear:
  9. iReport 3.7

  10. Press Next >, and accept the terms of the License Agreement.
  11. iReport 3.7

  12. If the Verify Certificate dialog box appears, click Continue.
  13. iReport 3.7

  14. Press Install, and wait for the installer to complete the installation.
  15. iReport 3.7

  16. After the installation is done, press Finish and close the Plugins dialog. If the IDE requests for a restart, then do it. Now the IDE is ready for creating reports.

iReport 3.7

Creating reports

We have already learnt about creating various types of reports, such as reports without parameters, reports with parameters, reports with variables, subreports, crosstab reports, reports with charts and images, and so on. We have also attained knowledge associated with these types of reports. Now, we will learn quickly how to create these reports using NetBeans with the help of the installed iReport plugins.

Creating a NetBeans database JDBC connection

The first step is to create a database connection, which will be used by the report data sources. Follow the listed steps:

  1. Select the Services tab from the left side of the project window.
  2. Select Databases.
  3. Right-click on Databases, and press New Connection….
  4. iReport 3.7

  5. In the New Database Connection dialog, set the following under Basic setting, and check the Remember password checkbox:

Option

Value

Driver Name

MySQL (Connector/J Driver)

Host

localhost

Port

3306

Database

inventory

User Name

root

Password

packt

iReport 3.7

  1. Press OK. Now the connection is created, and you can see this under the Services | Databases section, as shown in the following screenshot:

iReport 3.7

Creating a report data source

The NetBeans database JDBC connection created previously will be used by a report data source that will be used by the report. Follow the listed steps to create the data source:

  1. From the NetBeans toolbar, press the Report Datasources button. You will see the following dialog box:
  2. iReport 3.7

  3. Press New.
  4. Select NetBeans Database JDBC connection, and press Next >.
  5. iReport 3.7

  6. Enter inventory in the Name field, and from the Connection drop-down list, select jdbc:mysql://localhost:3306/inventory [root on Default schema].
  7. iReport 3.7

  8. Press Test, and if the connection is successful, press Save and close the Connections / Datasources dialog box.

iReport 3.7

iReport 3.7 Learn how to use iReport to create, design, format, and export reports
Published: April 2010
eBook Price: $23.99
Book Price: $39.99
See more
Select your format and quantity:

Creating a simple report

We are going to create a report, which shows the list of products. Just follow the listed steps:

  1. Go to File | New File….
  2. Select Report from the Categories: section and Report Wizard from the File Types: section, as shown in the next screenshot:
  3. iReport 3.7

  4. Press Next >. Select the Simple Blue layout and press Next > again.
  5. iReport 3.7

  6. Enter ProductListNB.jrxml as File Name:, and Browse… to the reports folder.
  7. iReport 3.7

  8. Press Next >.
  9. iReport 3.7

  10. Select inventory from the Connections / Data Sources options.
  11. Write the following SQL command as the query:
      SELECT ProductCode, Name, Description
      FROM Product
  12. Press Next >. You will see the following screen:
  13. iReport 3.7

  14. Select all the fields, press >>, and then press Next >.
  15. Press Next > again without selecting any group.
  16. iReport 3.7

  17. Press Finish. You will see the following output:
  18. iReport 3.7

  19. Click on the Preview button to see the output, as shown in the following screenshot:
  20. iReport 3.7

  21. You can design the report in the Designer section as per your design requirements.

Creating a parameterized report

We are going to create a report in NetBeans that shows the personal information of a particular customer. Follow the listed steps:

  1. Go to File | New File….
  2. Go to File | New File….
  3. Select Report from the Categories: section and Report Wizard from the File Types: section.
  4. Press Next > and select Simple Blue and press Next > again.
  5. Enter ParticularCustomerNB.jrxml as the File Name:.
  6. Browse… to the reports folder.
  7. Press Next >.
  8. Select inventory from the Connections / Data Sources drop-down list.
  9. Write the following SQL command as the query:

    SELECT * FROM Customer

    iReport 3.7

  10. Press Next >.

    iReport 3.7

  11. Select all the fields, press >>, and then press Next >.>>
  12. Press Next > again without selecting any group.
  13. Press Finish. You will see the Designer view of the report.
  14. From the Report Inspector (see bottom left of the designer), select Parameters. Right-click on it, and click on Add Parameter.
  15. iReport 3.7

  16. A parameter named parameter1 is added to the Parameters list. Select parameter1, and go to the parameter Properties window (see bottom-right of the designer).
  17. iReport 3.7

  18. Change the Name to customerNo.
  19. Change the Parameter Class to java.lang.Integer.
  20. Check the Use as a prompt checkbox.
  21. Now, click on Report query (beside the Preview button), and replace the query with the following one:
      SELECT * FROM Customer
      WHERE CustomerNo = $P{customerNo}
  22. iReport 3.7

  23. Press OK and Preview the report. Input the customerNo, and see the output.

Summary

We have seen that creating iReport reports in NetBeans makes the process of developing and managing reports easier. We have got an initial idea of creating reports in NetBeans. In the same way, we can create the more complex reports (subreports, crosstab reports, reports with charts, and so on) as well.


If you have read this article you may be interested to view :

iReport 3.7 Learn how to use iReport to create, design, format, and export reports
Published: April 2010
eBook Price: $23.99
Book Price: $39.99
See more
Select your format and quantity:

About the Author :


Shamsuddin Ahammad

Shamsuddin Ahammad is a Senior Lecturer and the Course Coordinator at Daffodil Institute of IT, Bangladesh. He has been teaching Java, Programming Methods, and Database Systems since 2002. He has experience in supervising hundreds of academic projects. Shamsuddin has a Masters degree in Management Information Systems (MIS) from Daffodil International University, Dhaka. He obtained the BSc(Hons) degree in Computing & Information Systems (CIS) of NCC Education Ltd, UK and London Metropolitan University joint programme from Daffodil Institute of IT. Before that, he completed the IDCS & IADCS of NCC Education Ltd. He is an Additional Reviewer of Conference on Quality Engineering in Software Technology (CONQUEST) organized by International Software Quality Institute (iSQI) in Germany. He is the author of book titled iReport 3.7 published from PACKT Publishing in March 2010.

Books From Packt


Joomla! 1.5: Beginner's Guide
Joomla! 1.5: Beginner's Guide

Getting started with Audacity 1.3
Getting started with Audacity 1.3

CMS Made Simple 1.6: Beginner's Guide
CMS Made Simple 1.6: Beginner's Guide

Apache MyFaces 1.2 Web Application Development
Apache MyFaces 1.2 Web Application Development

MySQL Admin Cookbook
MySQL Admin Cookbook

NetBeans Platform 6.8 Developer's Guide
NetBeans Platform 6.8 Developer's Guide

ZK Developer’s Guide
    ZK Developer’s Guide

Groovy for Domain-Specific Languages
Groovy for Domain-Specific Languages


Your rating: None Average: 4.8 (6 votes)
thanks aloooot by
so i want to integrate this .jrxml in my java web project....... How i can do it??? if u can help!!
ireport3.7 by
Very good!!!
Thanks by
Thank you so much....Good one....
he heee by
Thank you very much and very good tutorial for me.
need more help by
what a nice post.. and i need a little help by the way. hmm.. how can we connect this i report with our project? for example : i have a "Report" button. and when i click that button, i can view my selected record. thank you. send to my email, if you like to help me.. and i will verry thanl you with your help -- manan_suki@hotmail.com
hi by
plz tell me how to generate report from jbutton handler that is designed allready.
ferry good by
i have read it and ferry interesting to more learn, and i have been learning about it, thank you...... i hope can create and use i report.
Thanks a lot by
it is very useful for newbie
Thank You!!! by
thank You!!!! It is Useful and Proper help...

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Y
v
G
r
3
d
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software