The Main Features of iReport Plugins For Netbeans
The following list describes some of the important characteristics of iReport:
• 98% of JasperReports tags supported
• Visual designer wysiwyg with tools for draw rectangles, lines, ellipses, text fields fields, charts, sub reports...
• Built-in editor with syntax highlighting for write expression
• Support for Unicode and non Latin language (Russian, Chinese, Korean,...)
• Document structure browser
• Integrated compiler and exporter
• Support of all JDBC compliant databases
• Support of all kind of JRDataSource
• Wizard to create automatically reports
• Support for sub reports
• Save backup
• Support for templates
• Facilities for fonts
Creating a NetBeans database JDBC connection
- Select the Services tab from the left side of the project window.
- Select Databases.
- Right-click on Databases, and press New Connection….
- In the New Database Connection dialog, set the following under Basic setting, and check theRemember password checkbox:
Option | Value |
Driver Name | MySQL (Connector/J Driver) |
Host | localhost |
Port | 3306 |
Database | inventory |
User Name | root |
Password | packt |
- Press OK. Now the connection is created, and you can see this under the Services | Databasessection, as shown in the following screenshot:
Creating a report data source
- From the NetBeans toolbar, press the Report Datasources button. You will see the following dialog box:
- Press New.
- Select NetBeans Database JDBC connection, and press Next >.
- Enter inventory in the Name field, and from the Connection drop-down list, selectjdbc:mysql://localhost:3306/inventory [root on Default schema].
- Press Test, and if the connection is successful, press Save and close the Connections / Datasources dialog box.
Creating a simple report
- Go to File | New File….
- Select Report from the Categories: section and Report Wizard from the File Types: section, as shown in the next screenshot:
- Press Next >. Select the Simple Blue layout and press Next > again.
- Enter ProductListNB.jrxml as File Name:, and Browse… to the reports folder.
- Press Next >.
- Select inventory from the Connections / Data Sources options.
- Write the following SQL command as the query:
SELECT ProductCode, Name, Description FROM Product
- Press Next >. You will see the following screen:
- Select all the fields, press >>, and then press Next >.
- Press Next > again without selecting any group.
- Press Finish. You will see the following output:
- Click on the Preview button to see the output, as shown in the following screenshot:
- You can design the report in the Designer section as per your design requirements.
Creating a parameterized report
- Go to File | New File….
- Go to File | New File….
- Select Report from the Categories: section and Report Wizard from the File Types: section.
- Press Next > and select Simple Blue and press Next > again.
- Enter ParticularCustomerNB.jrxml as the File Name:.
- Browse… to the reports folder.
- Press Next >.
- Select inventory from the Connections / Data Sources drop-down list.
- Write the following SQL command as the query:
SELECT * FROM Customer
- Press Next >.
- Select all the fields, press >>, and then press Next >.>>
- Press Next > again without selecting any group.
- Press Finish. You will see the Designer view of the report.
- From the Report Inspector (see bottom left of the designer), select Parameters. Right-click on it, and click on Add Parameter.
- 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).
- Change the Name to customerNo.
- Change the Parameter Class to java.lang.Integer.
- Check the Use as a prompt checkbox.
- Now, click on Report query (beside the Preview button), and replace the query with the following one:
SELECT * FROM Customer WHERE CustomerNo = $P{customerNo}
- Press OK and Preview the report. Input the customerNo, and see the output.