Java for Beginners - Build a Java report engine with Eclipse, Jasper Reports and Jaspersoft Studio | Lorenz DS | Skillshare

Java for Beginners - Build a Java report engine with Eclipse, Jasper Reports and Jaspersoft Studio

Lorenz DS, BI & DWH Solutions Architect

Java for Beginners - Build a Java report engine with Eclipse, Jasper Reports and Jaspersoft Studio

Lorenz DS, BI & DWH Solutions Architect

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
18 Lessons (1h 52m)
    • 1. Introduction

      5:26
    • 2. Data Adapters and Data Sets

      5:37
    • 3. Load Data from a Data Source (CSV)

      7:13
    • 4. Load Data from a Data Source (JDBC PostgreSQL)

      4:56
    • 5. Create a Project from a Dataset with the DataSet Query Editor

      5:16
    • 6. Designing Reports with Jaspersoft Studio

      9:11
    • 7. Jaspersoft Studio Report Structure

      5:01
    • 8. Adding Parameters and Custom Filters

      5:42
    • 9. Adding Fields and Sort Fields to Reports

      8:39
    • 10. Reports and Sub-Reports

      10:17
    • 11. Using Variables in Reports

      7:24
    • 12. Adding Charts and Visualizations to Reports

      11:00
    • 13. Building a Java reporting application in Eclipse/NetBeans

      4:18
    • 14. Setting up the Java Libraries in Eclipse/NetBeans

      3:03
    • 15. Build a Java Reporting Application to Compile, Fill & Export Reports

      5:59
    • 16. Connecting the Java application to a Database (JDBC)

      4:06
    • 17. Passing parameters to the Java application (prompting)

      4:19
    • 18. Run the Java reporting application from the command line

      4:40
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

39

Students

--

Projects

About This Class

Learn to build a Java application to generate dynamic content and reports with Jaspersoft Studio and Jasper Reports through this step-by-step tutorial. This course takes you through the basics of Jaspersoft Studio and Jasper Reports. Connect to different data sources (JDBC, Flat Files). Build complex data set queries and customize reports using sub-reports, visualizations, and charts. Finally, we will also build a Java application to compile, fill and dynamically export reports to various formats (PDF, HTML, XML, XLS etc.).

..Learn to build a report generation engine in Java with Eclipse/NetBeans!

..Learn to design Java reports in JasperSoft Studio..

..Add custom parameters and variables to your report..

..Build, compile and run your reporting application from the command line!

The course contains training materials, where you can practice, apply your knowledge and build an app from scratch. The training materials are provided in an Excel file that you can download to your computer.

Good luck and hope you enjoy the course.

Course content:

The course consists of the following modules:

  • Introduction and Course Layout

  • Data Adapters and Data Sets

  • Connect to a Data Source (CSV) - Exercise

  • Connect to a Database (JDBC) – Exercise

  • Create a Report Data Set using the Query Editor – Exercise

  • Design a Report with JasperSoft Studio

  • Add Parameters and Custom Filters to Reports – Exercise

  • Add Fields and Sort Fields to Reports – Exercise

  • Reports and Sub-Reports – Exercise

  • Use Variables in Reports – Exercise

  • Add Charts and Custom Visualizations to Reports – Exercise

  • Build a Java Reporting Application

  • Setting up the Java Application Libraries – Exercise

  • Build a Java Reporting Application to Compile, Fill and Export Reports – Exercise

  • Connect the Java Application to a Database (JDBC) – Exercise

  • Run the Java Application from the Command Line – Exercise

Who should follow this course?

  • Students that want to learn the basics of JasperSoft Studio/JasperReports.

  • Software Engineers that want to learn how to build a report engine in Java, using JasperReports, an open-source Java library.

  • Business Intelligence professionals that want to learn how to design reports in JasperSoft Studio.

  • Managers considering using JasperReports/JasperSoft Studio within their organization.

Meet Your Teacher

Teacher Profile Image

Lorenz DS

BI & DWH Solutions Architect

Teacher

Hi there!

Hi there. My name is Lorenz, I am a certified IT professional with several years of experience working as a consultant and functional analyst, mainly in the Business Intelligence domain.

Working experience:

I have worked for clients within the Energy and Financial sector, and have been involved in the roll-out of Business Intelligence and Data Warehouse projects and the implementation of BI solutions.

As an instructor, I want to share my knowledge and experience in BI and Data Visualization software. During these courses, I will explain the basic concepts, but also tips and tricks for creating Visualizations and Reports that best suit your purpose or the purpose of your end-user.

Course topics... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: hi and welcome to this tutorial in building a chapel reporting application with Jasper Reports and Jaspersoft Studio. In this tutorial, we're going to learn how to build a chop application eclipse. It's going to create reports dynamically using just reports and jaspersoft studio. So what is Jasper reports Jasper reports, is basically a chapel library. It's an open source library developed by Jaspersoft, so you don't need any license. Just reports can be embedded in a job application to dynamically create contents and create reports. So it's not a standard application, but it's rather a library could be used to create a dynamic reports job. So what is Jaspersoft Studio Jesper? Self Studio is basically a report designed to for Jasper Reports and replaces the previous I report, Designer Toe by Jasper Soft. Jaspersoft studio is also Eclipse based, So if you're familiar with clips, you might recognize that the interface off Jesper Soft video is quite similar to eclipse. So within the sectorial, we're going to use Jaspersoft studio who designed the layout off our Jasper sign file, and Jesper Salt City will basically create next time l with the layout off our transfer design file. Once we created the Design file and Jasper Self Studio. We can compile Phil and export this design file to a report using either Jasper Self Studio or using Jasper reports, which can be embedded into a chopper application. So, Jasper reports, is a chapel library, and we can use the Jasper reports. Libraries to compile, fill an export are desperate for design file to a report. So what in the sectorial, we're going to create a job application with dynamically generate reports. So we're going to connect our job application to a data source, which can be a possible SQL database, a CSP or XML file. A Chava Beans collection It's on. In this tutorial, we're going to connect to a Osprey SQL database and later on in scores. You can also download these facts CSP files. After that, we're going to use Jasper South Studio to design or report so we can create a basic report design file in Jasper South Studio, and this will generate an XML file with the structure off our report. After that, we're going to use a clips, which is a job i d to build a job application to compile our job design file. to H. Asper file, but also going to connect our application for prosperous school database and then fill our report for the data from our database and export the report to a customer's Pdf file, which contains the structure of our design file and also the data from our database. Jasper Reports allows you to export this report into different formats. Second year exported html PdF and so on. So what are we going to learn in the scores? After we've had the introduction section, we're going to look at data doctors and data sets within Jaspersoft studio. We're going to connect experts art studio to a data source and the CSP fell and itchy BBC database connection. We're going to look at how we can add a CSP data source, and we're going to look at how we can connect to the database using age 80. Bc connection. After that, we're going to the final data set off a report so this will contain all the fields that we're going to use within our reports. And we're going to design your report with Jaspersoft studio, so we're going to learn how we can add tables, charts and visualizations to our reports, we're going to learn how we can add pyramids to report and use the spare images to create custom filters. After that, we're also going to learn how we can add field story ports or future basically the data elements or the columns within your report. And we're also going to look at some reports, some reports of one of the key features off Jasper South Cirio and allow you to add reports within a main report. And they're also going to learn how we can use variables and at custom charts and visualizations to our reports. And after we have created our Jasper reports the sign file using Jasper Salt Studio, We're going to leave Jasper South Studio and go to Eclipse. We're going to use Asprey ports to build a chopper reporting application. It's going toe build reports based on our Jacksonville cipher. We're going to learn how we can set up our chapel libraries and also build a job application to compile Phil and export our reports to a Pdf file. Then we're going to connect our job application to a database, and after we've built our job application, we're going to compiles application and then we can actually run our application from the common line. Generate reports before we get started. There are some requirements. With this tutorial. We're going to use a past preschool database. And of course, you also need to Jesper Self Studio and Jesper Reports, which cries Java development Kids 1.6 or hired in this story. We're going to build a job application eclipse. It's also highly recommended to use a chap I d, such as Eclipse or Not Beans and also some basic knowledge of job and a school is very useful. Okay, so let's get started on the open. George arrested its course. 2. Data Adapters and Data Sets: Okay, So what we're going to the next is create a connection to a data source within Jasper Self Studio. And we're going to do this by creating a data chapter. Data adapter is basically a connection to a data source that can be created in just percent studio, and this connection is basically stored in a simple XML metadata file just for self Studio contains multiple data adapters to connect to different data sources. So there are data adapters to connect to a simple CS fee or Excel file to adjacent file to an XML file, for example. But you can also use a data adapter in Jasper Self Studio to connect to a database. This can be, for example, Bosc Riesco well, or a sequel server. Oracle Database. Using a database JBC data adapter, you can also create a data adapter to connect to a Java beans collection. A Java means collection is basically data store within Java, and you can also connect to a Java beans collection using a Java beans data adapter. So, as you can see, there are multiple data adapters to connect to multiple different data sources in Jasper Soft studio and what we're going to do next. It's at a simple CSP data adapter. When we're going to create a CSP data adapter, we need to specify the file location. So this is the location where our violence located and also the columns. You can also specify currency and date patterns and also column and field separators to read the data from the CSP foul. And then, of course, we can also configure the encoding off RCSC file. So these are all para meters that we can configure in Jasper Soft Studio. When we create our data adapter on the right side, you can see the sample XML structure off our data adapter so you can see the location of our file. You can see the columns, date and number patterns and so on. So each time we create a new data adapter in Jasper Self Studio, Jasper Self Studio will also create a new XML file off this data adapter. In the second exercise, we're going to create a data adapter for age 80. Bc database connection So this is a Java database connection to our past three SQL database . A. Z can see this data adapter uses a database. Ural, which contains the host deport and also the service idea of our database. We also need to specify or database user and password to connect to our database. And we also specify the JD BC driver On the right side, you can see the sample structure off R J D B C database Connection data adapter for possible SQL. And this data adapter is also generated by Jasper Self Studio. So once we've created our data adapter to connect to our data source, which can be or see SV fell or busker SQL database, we can create a data set to specify the fields that we're going to use wooden our report. So within the data set and query editor in Jasper Soft Studio, you can specify which fields you want to include in your report. You can also add sort options, for example to sort fields alphabetically, and you can also add filters to filter own certain fields. So in this example, you see or data source, which is a posterior school database, and then you see the data adapter to connect to this data source in Jasper Self studio and then you can see on the right side we have or data set and query editor to connect to our data adapter and select certain fields and tables from our past your school data source So you can see all the tables within our database schema, and you can also see the select curry to fetch the data from our database. And once we created this data set within our report, and you can also see the fields customer named province, region, customer segment, total orders and total sales within our data sets. And once we actually created this data sets, but in a report, we can use the fields from our data sets to create tables or visualizations within our report. So in the following exercises, we're going to connect to a CSP data source using a CSP data adapter. And within the cereal, you can download the exercises Zip folder, which contains five different CSP fouls. Each CS fee file contains one table, so you have a table for customers, orders, products, region managers and returns. We can create a different data adapter for each file and then create a data set within a report so you can download the CSP files from discourse and what in the second exercise, we're going to use a database connection using a boss Chris Cable, JBC data adapter. And basically, there's one table for each See SV file within this tutorial. Um, So what you can do is download the CSP fouls from this tutorial and create a table for customers, orders, products, region managers and returns on your database. In this case, I'm using a busker SQL database. But you can also use an Oracle database or sequel server database just as you like. Or you can also use a CSP data adapter. You can also install bus Crisco will for free from the posterior school website, and you can create a different table for each file and load this file within your database . Okay, so what we're going to the next is go back to Jesper Self Studio and create our data adapters to connect to our CSP data source and also to our prosecutor school KTBC data source 3. Load Data from a Data Source (CSV): Okay, So once you've set up just for soft studio, you can start by creating a data adapter. A data adapter is basically an XML file which contains information on our data source. So the data adapter does not contain data itself, but contains information such as the location and the type of connection that we're going to use to connect to our data source. So to create a data adapter, you can go to the Repository Explorer and at a new data adapter, we can select the type of data adapter in the data adapter wizard so you can choose a CS fee foul. You can choose a Java beans collection HKTDC connection to a database or other types of data sources. To start, we're going to use a CSP foul to create our first data adapter. So I select TSV file, go to next, and then you can create in the data adapter. I'm going to name this one customers. I can select my CSP file where I can type the girl to my CSP foul. So I select my customers CC found. As you can see, the query execute her motives unchecked because we want to read to see if you file directly , but we can also read to see his fee file using a CSP specific query language. So for now, I'm going to uncheck this check box. We're going to retrieve the column names from the first row over Foul. As you can see in my CSP foul, my calm names are in the header off my farm, so I'm going to get the column names from the first row off my file. But as you can see, Jesper Soft doesn't recognize these as different columns. And that's because when I go to separators, my field separator is kama instead of semicolon. So I should changes to Sammy Cahn. My roasts are separated by new Windows Line feats. If I go back to columns, I delete this column and I click on the get column names from the first row of to file again. Then you can see that Jesper Self now recognizes two different columns. I can also add custom columns by going to at or delete columns by going to delete. Um, I can also specify my date patterns for the dates within my sees FY foul as you can see my CSP file doesn't contain any dates, so I don't define a date for months. I can also define a number for months, but as you can see, I don't have any numbers as well in my CC foul. If you want to create a date pattern, you can just simply go to create and select a time or date pattern in the templates for Mitt. And you can see that you have different formats for dates and numbers. But for now, I'm just going to remove the sport. I can also select a time zone, and I can also select an encoding off my data source. So, for example, I can set this to utf eight when I now click on tests that I can test if the connection to my data source is successful. I also skipped the first line because the first line contains my column names and then I go to finish. As you can see, my new data adapter is create. If I want to edit this data adapter, I can simply right click and go toe at its data adapter, and I can add it. My data adapter in here. I can now create a new data adapter. I select a cease fee foul, and I select my file orders. I changed the separator settings, and for this file I'm going to define a date and number pattern because I'm using some dates and numbers within my CSP file. So I opened my CSP file, and as you can see, my dates are defined in a year, year, year, month, month, day, day for Mitt and my numbers use a dots decimal separator. So I now go back to Jesper Self Studio. I defined my date patterns, which is you read your year, month month. They they and I defined my number pattern as well. I select my encoding scheme, and I called his data adapter orders. I do the same for my returns. So I created new data adapter, which I call returns, and I did it seem for products and region managers. - You can also simply copy a data adapter by going to Dublin Kate Data adapter. And then you can rename this data adapter to, for example, region managers. I click finish, and as you can see, all my new data adaptors have been at it within my repository Explorer 4. Load Data from a Data Source (JDBC PostgreSQL): Okay, So what we're going to do next is created connection to a database. So, as you can see, I have a boss create school database. And in its database, I have a schema which contains a few tables customers, orders, products, region managers and returns. And I'm going to load the data from these tables into Jesper Reports Studio. So as you can see these stables or the Samos, my CS £5. So I actually loaded the data from my CSP falls into these post grad school tables. You can also view the data, you hear. So these are my customers. We also have the same for orders and the stable. We have all the order details for each of the customers, and then we also have a table for products which contains all the product details, product categories and so on. We have region managers and returns us well. So what we're going to the next is go back to Jasper Self Studio and built a data adapter that can connect to this database. So first I remove my previous data adapters, and then I add a new data adapter using age 80 bc for a java database connection. I'm going to use a bus cree SQL database. So I'm going to select my boss Cree SQL database driver in here. You can also use another database. It's listed in the driver's list in here. As you can see, you can use a connection to Cassandra to mongo DB sequel server and so on. But for now, I'm going to create a database connection to a boss Cree SQL database. I'm going to enter my jdb. See Earl, the name of my database. It's called past three This My host name is my local host and my port is 5432 I'm going to enter my user name, which is also boast Chri s and I'm going to enter my passwords. We're going to test the connection and is it conceded connection is successful. I'm going to call this data adapter past three SQL Data adapter. Then I'm going to create this data adapter. And as you can see, my data adapter is now at it within my repository to edit this data adapter, I can go to add it data adapter to add a property to this connection, you can also go to connection properties and at a new property and value. And you can also add a class spot to a Java jar driver within the Repository Explorer. You can also set up a connection to a Jasper Reports server. Through this, you can create a new Jess Report Server Connection where you can enter all your connection details digest for report servers, basically a Java Web application that allows you to schedule some of your reports and also share your reports within your organization. For now, we're not going to focus on the Jasper Reports server, but we're going to use data that we load from our data adapters within our custom reports. Because data adapters basically use an XML structure, you can also easily export these data adapters to an XML file. So to do that, I right click on a data adapter. For example, I select my Osprey SQL data adapter when I right click and I click export to file, then I can save this data adapter as an XML file. Under my workspace, for example, I can say with within my reports workspace when I go to my workspace for where you can see my data adapter XML file in here. And, of course, you can also import a new data adapter XML file by going to import from work space. 5. Create a Project from a Dataset with the DataSet Query Editor: Okay, So once we've created all our connections to our data sources using data adapters within Jesper Soft studio, we can actually start building our first project. So let's go to the Project Explorer and just simply click on a new project. As you can see, the Wizard gives you a few options to create a Jesper Self studio project. You can also create a new Java program or a plug in. For now, we're just going to create a new Jesper Reports Project, and we're going to name this customers report. So after you finished creating new project, you can see that there's already a job are run Time Environment Systems Library and also a Jasper Reports Library. Um, you can see all the jar files within your job, runtime environment and also the jar files for just for reports within thes folders. So what we'll do next is create a new report design file where we can specify and design or report. So, as you can see, there are a few templates. You can also build custom templates, but for now, we're just going to select a simple blue template. We're going to name this XML design file customer report or just customers, and we're going to place this XML design file under the customers report project. Next, we need to specify which data adapter we're going to use to load the data into our new report. So you can select one of the C S V date adapters, for example, customers. And here you can select all of the data set field that you want to add to this data sets the data said is specific to your report. Where's the data source or data adapter is based on your repository. So for now, I'm just going to add all of the data set Field store report data set. And as you can see, my new data set from my report is created, and also my new report design file will be created. You can see that the new design file has been at it to your custom report project, and you can add new designs within the design tap. You can also see the XML source within the source step, and you can go to preview to actually compile and preview your report. You can also go to the data set and query editor dialog to change your data sets. So suppose I want to use a new data adapter and select my possibly SQL database connection . Then I specify my data adapter. I use SQL as a query language and I can simply select my tables within possibly SQL. So I have a few tables. I have a customer stable order, stable product, table region managers and return stable. And I can simply select the stables by entering my select statements. And then when I go to diagram, I can see all of my columns on my table. When I didn't read those fields, then you can see that the columns have been added to my data sets. You can also specify para meters sorting for your columns at a filter to re comes and also preview your data sets by going to refresh preview data and then you can actually preview the data within your data sets. You can also see that the data set fields in your report have been added to the outline of a report by going to fields. Then, he conceded, the customer name, province, region and customer second fields have been added to report 6. Designing Reports with Jaspersoft Studio: Okay, so after we've added our data source in jazz percent studio, we can actually start designing our report in RT Eric Similar design file jaspersoft Studio . So when we open our report design file in Jasper starts video, we can see our report design fell product category seals, pure XML. Then you concede it. We have three different steps. We have a design that a source step and a preview tep Within the design that we can actually design or report, we can add visual elements such as titles, shards, visualizations and so on. And each time we add a new element within our design. This will also be added to the store step which contains our dear XML sort. So basically, our XML sore structure is altered generated Each time we add a new visualization within the design step, we can also preview our report when we go to the preview Depp and from there we can also compile and run our report. As you can see, there are different elements that we can add to a report. We can add perimeters, fields, sore feel sense, what it is recommended to edit your report within the design, But You can also add it to report within the source step. So, for example, when you add it one of the properties off your report within the source XML coat. This will also be reflected within the design there and also the outline of your report. So, as you can see, there are many different elements we can add to our report. We can add para meters permitted are basically values that we can pass to our report, for example, when we generate a report from a job application. So apparently this can be default values which always stayed the same. Or we can enable these permits for prompting, which means that we can enter different values for these pedometers when we run our application. For example, when we run our job application from the common Line, we have two different types of para meters. We have built in parameters which are basically perimeters that are already available in Jasper Soft Studio, such as report context, a report connection it's on. So these are the perimeters that you see on the right side of the slight. So all these perimeters report context, report, collection, report, time zone are old default para meters building permits that are generated by Jaspersoft studio. We can also define our own para meters. Um so when this exercise, we're going to create two para meters for feel the province of Salta region and we're going to add these perimeters to our report and we can of course, enable these pyramids for prompting and to use one of the building pyramids or one of the user defined perimeter said we created ourselves within our report we can use this index very specified perimeter name. And of course, there are different ways we can combat para meters within our report. For example, we can create custom fielders by embedding these para meters within the query of our data sets within a data set query editor and this way began at a custom filter the filter on certain provinces or regions. Example or we can also in bad to these perimeters within our visualisations. Next to that, we also have fields, so feuds or the data elements within our report and they are defined within the report data set query editor So feels air basically interface between our data source which is Arteta chapter and our reports so For example, we can have a data source, which is a prosperous SQL database, and then we can create a data adapted to connect to our data source and we could define our fields and in the fields will be the columns within the table over database. You can also create custom fields within your data sets, and we can also sort our fields alphabetically and to use fields within tables, charts or visualizations. You can add this index where we specify field name One of the key functionalities off Jesper Self Studio is also that you can add some reports to a main report within Jasper's art studio, and some reports are basically reported are embedded within a main report. And we can also pass perimeter values from our main report to our SUP report. So people surveyed powerful because we can use the same data connection a sui use, but in the master report. But we can also create a custom new data source connection, and later on in this course, we're going to create a self report which we're going to embed within our main Jasper report. So as you just saw, we have para Meters, which are people values that we can pass to report next to that. We also variables. Variables are used to store the result of a calculation within the report, an extra that we also have built in variables which are variables that are generated by Jesperson Studio. Such a page number report count. But we can also define our own user defined variables, so we can, for example, create variables with aggregations calculations and so on. So, as you see on the right side, you have the great out variables which are built in variables. These are generated by Jasper Self Studio, and we also have a user defined variables. Total orders count total see yourself and later on in this course, we're also going to specify these two custom variables and to use a variable within your reports. We also use this in Texas, where we specified the variable name. There are different visualizations that we can add to our report when we design our reporting jaspersoft studio, and we can find these visualizations within the bullets of just stopped studio. So you have basic elements such as charts, spider charts, custom visualizations, frames, lines and so on. The next that you also have composite elements and within this tutorial were mainly going to focus at charts and tables. So what? In the first exercise, we're going to create a new Projects folder within Jesper Stop Studio, and we're also going to add a Jesper Design file, which we're going to call customers. Start Chair XML on. We're going to add a title to report in a short description. So the title of a report will be customers, and we're also going to add a description. This report has been generated by Jasper Salt Studio next to dance programs at a table to report, and this table is going to give an overview of all the customers within a report. So we're going to call the stable customers over you on the table should consist of the following columns customer name, province, region customer segments and these goals will be populated by the fields within our data sets. So after we've created our customers design found, we're going to add to para meters to report filter region and filter province. So these will be to new user defined para meters, and we're going to use these two parameters within our data set query editor to fill their own records for a certain province and region. So we're going to add these two parameters to the query of our data sets query editor Next that are also going to add to custom fields to report. And so we're going to add to fields total orders and total sales. Total orders will be the number of orders placed by customers, and then total sales will be the total sales amount for each customer. So we're also going to create two new columns within our table for total orders in total sales. And we're also going to sort the records within our customer stable alphabetically. We're going to sort them first on customer segments that secondly, we're going to sort the records on customer name. After that, we're going to create a separate port, which we're going to call product category seals, and this up report will give an overview off the product category seals for each customer segments. So we're going to add a new table which we're going to call product category sales per customer segments on this table should contain the following columns. Customer segment product category, products up battery and also to new user defined columns, which we're going to call total orders and total sales. After that, we're going to embed ourselves report product category seals within our main customers report, and we're also going to create two variables. We're going to create a variable total orders count and total sales. Some I'm total orders count will be to some off the field. Total orders and the total system will be to some of the field total sales. And after we've created these two new variables, we're also going to embed these two variables within the summary section off our main and sup report. So after we've added the two tables for a major report on our self report, we're also going to add some charts and visualizations toe a report. So we're going to add a pie chart or total sales by customer segment and total number of orders by customer segments. But in our main reports, and we're going to add a stacked bar charts to our sub report. I'm 40 total sales by product category and product, subcategory and Rosa going to Addie stacked bar chart within our self report for a total number of orders by product, category and product subcategory. So let's not go back to Jesper Self Studio and start creating our customers Design file wouldn't jaspersoft so you 7. Jaspersoft Studio Report Structure: Okay, let's now look at our gear XML file, which is a design file of your report and have a look at the report outline. So in general, each report in Jasper Soft Studio has a following layout. Has a title. A page header, column header, detail column, footer, page, footer and summary. The title section basically contains the title of your report. This case I'm going to add a title, which is called Customers, and the title of your report can also contain a short description. You can also add a page header, which is a header that returns on each page off your report. This can, for example, be the name of your organization. You can also add a column header. In this case, the column had their uses the names of the columns within my table so you have a customer named Province region customer segments. The Details section contains the actual values of my columns, so this contains my actual data in my column footer. I can also add a simple footer for each column. This can be used to aggregate, for example, the total number of records or a total value in a certain column You can also add a page footer, which is going to appear on each page off your report. This can, for example, be the dates or the page number, and then you can also add a summary section within the summary section. You can add some summary statistics. You can add, for example, a by chart to summarize all your findings within the summary section. As you can see, you can also add some para meters para meters are basically input values that you can prompt when you want to run your report and in the fields. In this case or each of my columns. You can also add variables which can be used in your board. Also at script. Let's to your report. In this course, we're also going to go deeper into each of those elements. But first, let's go back to our main report and change the title off our report. So I'm going to change this title to customers. As you can see, my title is also updated in my outline, and I'm also going to add a description to my report. This report has been Generate it by Jaspersoft studio. You can also resize and move these elements within your report. I'm also going to add a page header by adding a new static text elements to my report. As you can see, this element has also been added to my page header and I'm going to call this page header Customers overview. And when I right click on my page header, I can resize this to my container to fit the width of my containers. So, as you can see, my element now fits the total width of my pay cheddar container. And when you go to properties, you can also change the font and size of your text. So I'm going to increase my phone size and when you go to source, you can see that there is an XML file generated based on the design that we created in our Gear XML file, so you can see each of the elements within the outline of a report. You can see the query string which contains my data set, and you can also see my fields, customer name, province, region and customer segment. You can see the title that has been at it and also the properties for the title within the tidal section. I can also see the page header Call him Header and the other elements within your report. So each time I change my design file, my source XML file will also be changed. When you go to preview, Jesper, Self Studio will preview your report. You can see our customer Steidl or description or pay Cheddar. Also, our column Heather the details section, which contains the details or the data off our report and at the bottom of the page, you can also see the footer off your report. 8. Adding Parameters and Custom Filters: Okay, so what, we're going to the next? It's at some para meter. So report bear meters are basically values that we can bess toe a report from, for example, a job application. While we're running our report, these pyramids can also be prompted. For example, when we want to run, are just for report from, for example, a Java application and then we can enter these perimeter values within our application. Barry meters can be used in many ways within your report for configuration, but also, for example, when we want to add a perimeter value to our select statements within our data set and query editor. So what we're going to do next? It's at a filter for the province and region within a report. And then we can pass certain values for provinces and regions. Toe filter on these provinces and regions would in a report. So what? I'm going to the nexus at two para meters by going to para meters and creating a new para meter. I'm going to call this perimeter filter region. And as you can see, this is a job out string class. I can also add a description, for example, this para meter. It's used to filter upper region. I can also select if I want to use despair omitted for prompting. And this way I can pass a certain value for experimenter from my chopper application while running the report. Um, I can also add a default value or expression so we can add one of these regions as a constant. What, In a report, I'm going to take this region and use it as a default value for my region Filter. Okay, so then we can save this para meter, and we can create a new perimeter to filter on the province. So I'm going to add a new perimeter called Filter Province and I'm going to add a description this para meter. It's used to filter per province. I'm also going to add a default value. So when I look into the customer stable on my database, I can also add this as a default value for my province. Okay, So, as you can see, we've now added the two para meters to our report, and now we can use thes perimeters within our report. So what I'm going to do is I'm going to go to my data set, Inquiry editor. And I'm going to use thes perimeters in the select statements where I gets the data from my database. So I'm going to add a wear kos and within the wear clothes, I'm going to add to conditions. I'm going to add a first filter on the province and I'm going to use the perimeter that we just added for province. So to use a perimeter in my report, I use dollar p and then within the brackets, I at my perimeter name, which is filter province. So this first condition is going to filter on the records where the province name within my customer stable is equal to the province perimeter. That I'm going to add a second condition ready customers region call him is equal to the perimeter filter region. And then once we added the where clause to our select statements, we can go to data preview to preview the data would in our data set. And as you can see on Lee, the provinces and regions, for none of it have been selected with in my data sets because this is also my default value for my perimeter. And if I now preview my report. Then you consider my to input. Parameters are also prompted so I can enter a value for my filters. And when I run my report you can now see that we get an overview of all the customers within the province in region off. None of it. If I now want to change the input values for my para meters, I go to show para meters and they can change these parameter values for example, to Ontario. And then I will only get the customers within province and region off Ontario. So if I now run this report, then you can see that I get all the customers within the province in region off Ontario. 9. Adding Fields and Sort Fields to Reports: to make our report more readable. We can also sort their records would know report according to certain fields. And we can basically do this by going to sort fields and then creating a new sword field. And we can sort the records when you report based on our feuds within our data set. Or we can also use variables to sort the records within our report. And what we're going to the next is first sort the fields on our customer segments and then sort of fields on each customer name within each customer segments. So we're going to add a first sort field for customer segments, and then we're going to add a new sort field for customer name. If we now go to preview and we run our report again, then you concede that I get all the records for province and region Ontario, which is my perimeter. And then my records are sorted first on customer segments and then on customer name alphabetically, so you can see that I get the customers for customer segments, consumer first. Then I get corporate home office, small business and then within each customer segments. My records are sorted based on the customer name alphabetically. To change the order off your sort fields, you can go back to your design and then if I place customer name on top of customer segments, my records will first be sorted on the customer name and will then be sorted on the customer segment. If we go back to the data set inquiry, dialogue, then you can also see that the new sort fields have been at it. Your data sets and here you can also change the order from ascending to descending, for example. Okay, What we're going to the next is at two new fields to our report for a total sales amount and the total number of orders for each customer to do this, I'm going to use the data from my order stable and I'm going to add a columns, sales and order I D. Um, but first I need to join my two tables. So at a joint to my select statement, and I joined the customer stable with the order stable, as you can see, my two tables or linked based on the customer name. So I joined the two tables on customer name and I select all the fields from my customer stable, and I select the order I d and also seals from my order stable. If we now go to diagram, you can see that the two entities, customers and orders are both length. And when we read the fields again in our data set, then you concede it order I D and sales have both been add it to your data set. If we go to preview, then you can also see the new two columns within your data set. But of course, you want to have the total number of sales and total number of orders for each customer, so we'll have to group these records. So I'm going to add a group by to my select statement, I'm going to group by customer segment. And then I also add my other customer fields. Province reaching and also customer segments have a total number of orders. I at a count to the order ID's, and I also did some off the seals. And then when I read my fields again, you can see that I get a better message, and this is because my customer name ah doesn't appear in my group by statement. So I need to change customer segment my customer name. This is a small typing error and now when we read the fields again, you can see that the two fields are at it. We can also change the names of these two fields. Example going to change this to total orders. And I'm going to change the second field too. Total seals. Then I read the fields again, and when we go to data preview, you can see the total sales amount in the total number of orders for each customer. So now when we go back to our report, you can see that the two fields have been at it within our hotline. And we can also add these two fields within our report. I'm going to attitude new columns within the column header by simply copy pasting one of the text elements. I called the first column the total orders because this will give me the total number of orders and then the second column I call Total Seals. And then we're going to enclose thes elements within a frame so that we can arrange the columns horizontally. Then, once we added the column, headers We can also add the column fields within the details section. So I just copy one of the text fields and then I ads my fields, total orders and total seals. I enclose my fields within a frame and then we can also arranged these elements within our free. And when we now preview our report, then you can see that the two new columns have been added to our report. 10. Reports and Sub-Reports: Okay. So once we added our main report, we can also add a sup report within our main customers report. Sup reports are actually reports that are inserted within your main report. So, for example, within our customers report, we can add a separate port for products that gives us a total number of orders and total sales for each product category within each customer segments. Step reports are very useful because they allow you to add multiple data sources within your main report. So what we're going to do next is at a new report to our customers report project. And I'm going to name this report product category seals. And I'm going to add this to your ex Mel file to the customers report project, and then we select our past three SQL Data adapter and then we can select the fields that we want to add to our reports. So I want to add to the product category except category, also the customer segments within the customer stable and also the total sales and total number of orders. So I need to join my customers orders and products stable, and we can simply drag and drop the stables to our diagram. And then I can either join the stables manually or I can join them using the diagram. So I joined customers name with customers, name in the order stable, and I join the product name with the product name in the order stable. And then I select the columns that I want to add to my report. So I select customer segments product category except category, and they also add order I D and seals don't go to text. And then to get the total number of orders, I simply count the order ID's and I also like to some of my sales amount. And then, of course, we also need to add our group by statement and then we just at all our data set feuds and we grew by customer segment product category product subcategory. And now our new report has been generated. So I go to finish and then we can see our report product category seals. I'm also going to add the two para meters from my province and region, so I goto para meters create para meter. I call this perimeter filter province, and I add a default value and then I at the second perimeter for my region, call this fare meter filter region and then we can also add these two para meters to are rare class in our data sets, we can see our fields and we can also preview our data and then you can see that we get the total number of orders and total sales for each product category and each product subcategory within each customer segments. We can also add a page header. - We can remove the title. We can also remove the column footer that I'm going to add the few names within my column header and I'm going to add to the fields for customer segments product, category, product, sub category that I remove customer segments and then I have a customer segment product category product, subcategory, total orders and total sales. And now we also add the fields within the details section and I'm just going to copy Paste to feels from my main customers report and then my first field will be customer segment. The second field will be product category then. I also have product subcategory. I can remove customer segments and then we've added all the fields to our product category sales report. If I now go to preview that I can preview my product category sales report and then to improve the layout of our table. We can also go to design and then stretch all the content within our DDO section. And then if we go back to preview, then you can see our product getting re seals report for each customer segments. And then we can also sort the fields within our report by creating a new sort field and then I add a new sort field for customer segments. I also add a new sort field for product category and also for product subcategory. And if we now go back to preview, you can see that our records have been sorted by customer segments, product category and product subcategory. So what we want to do next is add this product category sales report to our main customers report. So if we go back to our customers Jerry XML main report, then we can add to the product category sales report as a soap report within our main report. By going to the SUP report elements and adding this Studi summary section within our report that I'm going to create a separate port using existing report, and then we select a report file from our workspace, and we select our product category seals. Sup report. We're going to use the same posture SQL database connection to feel our reports. So I'm going to select use same J BBC connection We go to next, then we add the para meters from, or mass report for Fielder, Region and Filter Province. We go to finish that, I'm going to move these up, report to the summary section within our main report, and also stretched the content within our summary section and then to move this self report more to the middle. Off my report. I just changed the really out. And then we can simply change the size off our sup report. If we now go to preview and we run our main report, then you can see that we get the customers overview and then we have our sub report product category sales per customer segment at the end of our report, 11. Using Variables in Reports: Okay, so what we're going to the next is have a look at variables within Jasper. Soft studio variables can be used within reports to restore the result off a calculation. This can be very simple calculations, but can also be more complex calculations. When we look at the variables within the outline of a report, you can see that there are some pretty find variables that Jesper Subsidy already creates. Apart from that, we can also define our own variables, and these a wrinkled user defined variables. So there are two types of variables. You have the default variables from Jasper Self Studio, and you have the user defined variables that you can create within this list of built in variables, we have the page number. The page number basically gives you the number of pages at a certain evaluation time. We have the column number, which counts a total number of columns within a report, and then we also have the report count on the page count for a total number of records that are processed within the report or on the page, and we have the column counts to count the total number of records processed during the current column creation, and each of these variables is actually calculated at a certain time. It's what we call the evaluation time. This can be either, for example, at the creation of a report or when we create a new page within our report. So, as you can see within the footer off our report template the variable page number ISS used twice and once it is executed at the current evaluation time and once it's executed at the time of the generation off the report. So the first time this page number variable is called, it will give us the current page because it's evaluation. Time is now, and the second variable, it's called is evaluated at report time, so this will give us the total number of pages within the report. So when we go to preview, for example, and we run or report, you can see in the footer off our report that the first page number gives us a current page for report because this is evaluated now and the second page number gives us a total number of pages within a report, because this is refreshed each time the report is generated. So if I go to the next page, you can see that now the page number is too. So I get paged to off six because each time I go to the next page, this page number increments and the second page numbers on Lee evaluated once at the time off report creation and what we want to do next is create to user variables to count the total number of orders, which is a some of the total orders field and then also the total sales amount, which is three, some off the sales amount. So I'm going to create two new variables by going to create variable, and I call my first variable total orders count and this is the sum of the field total orders. So I select calculation. Type some, and with an expression, I select the total orders field. And if you want, you can also enter an expression which gives you an initial value off your variable. We don't need to select any increment type because we don't need this variable to increment , but we need to set a reset type on the report level. So each time the report is generated, this total orders counts variable will be recalculated again. Um, I'm also going to add a new variable, and I'm going to call this variable total sales. This is also a some and within the expression editor, I select my total sales fields. I don't need to enter initial valuer increment type, but I do need to reset this type to report. We also want to reset this variable each time the report is created. And what we're going to the next is call these variables within the summary section off our report. So I'm going to add a new aesthetic text and we're going to call this total orders and I'm going to change the phone type to make more visible. And I'm also going to add a text for the total seals. And then, of course, we also add the result of our two variables. And I'm also going to change the phone type of our text field to make this more visible, the same as we did for two other text fields. That I'm also going to add a simple line just below my total orders in total sales. And then we can preview our report again. But now if we run the report, you can see that we get an error message and you can see the message below. Apparently, we couldn't evaluate or variable. So let's go back to our variables. And you can see that there is one thing that we forgot for the variables that is, to change the value class to a America type because our total orders and total sales are both in America and not string values. So we can change total orders, for example, to an integer, and we can change total sales too long. Um, so if I now save my report and I go back to my preview and we run the report again, then you can see that the total number of orders and total sales have been added to our report. 12. Adding Charts and Visualizations to Reports: Okay, so what we're going to do next is at some visualisations to the summary section off our report. So we're going to add a bi charts, and this pie chart is going to show the total steals for each customer segment. So I'm going to drag and drop one of the chart elements within my report. And then we can select the type chart that we want to add to our report. As you can see, there are different chart types. You have area charts, board shorts, a stack, charts, line charts by charts and so on. Um, I'm going to choose a by chart because I want to show the total seals for each product category. So I want to show the percentage or proportion of sales by product category. And then what I'm going to do next is at a Siris for my pie chart. I want to split my pie chart for each customer segments. I'm going to add a new Siri's they go to at I'm going to use the customer segment for my Siri's. Then I want to label each of my slices with the name of the customer segment, so I'm going to add a new label and I also use customer segment for my label names. And then the values represent the size of my slices. And for this I'm going to use the total sales amount. So I select total sales for my values. And then I just leave the default setting so I don't select an increment type. And then we want this pie chart to be created each time we reset the report. So I'm going to set resets on report and don't add any increment. Mexican CD pie chart is now at its and I'm going to add it just on top off the sub report within the summary section and then we can preview our report. Then we get an error message that one of our key values is duplicated. This is because one of our customer segment keys is duplicated or is present more than once within our pi data set. We can ignore this error by going to source simply adding a new property so that we ignore any duplicated keys and I'm going to set this to value true. And if we now preview our report again, then we can see that the pie chart is now add it to our report. We can also add a pie chart within our sub report. So if he now go back to the design tap and you go to the summary section, you can go directly to the SUP report. This will open the design found for a product category sales, a sub report and what we're going to the next. It's at a chart within our SUP report within the summary section. So I'm going to add a new band, 40 Summary section, and then we can add a chart to the summary section within our sub report. And suppose I want to show the total sales for each product category and product subcategory I can select the stacked bar chart and then we're going to add a new Siris for product subcategory. So I'm going to remove this Siri's and and a new one based on the field product subcategory , and now we're going to stack these products up categories for each product category. So I'm going to add a category based on the product category and to show the total sales for each product category and product subcategory, I'm going to replace the values by total sales. And we're going to create this chart each time we run our report. And if we now preview or run our product category seals sup report, then you can see that we get a chart at the ends off our sub report, with the total sales for each product category and each product subcategory. So we can now save this up report and go back to our main customers report. And if we now preview our main customers reporting in, then you might notice that we don't see the summary chart from the product category seals up report. This is because first we have to compile rcep reports. I'm going back to my separate port. Then you see that we have a jeer XML file, which is a design file for our separate board. And we also have the compiled jesper file. So I'm just going to remove previous compiled Jesper file and I'm going to re compile the product category sales report. So now you can see that I have compiled my product category seals report again, and I also have a new Jasper file. So I'm going back to my, uh, customers report and Then I preview my customers report again and I run the report again. Now you will see that the product category seals a chart will be added at the end of our sub report so you can see that the new chart has been added at the end of a report. So each time you use a sup report within a main report, you always have to compile the report again before changes take place within your main report. So what, we're going to the next? It's at a title to our charts. I'm going to copy one of the static text elements just above our chart, and I'm going to call this seals by customer segments. And I'm also going to add a new chart to show the total number of orders for each customer segment. So I'm just going to copy the by chart. I'm going to call this orders by customer segment. And then we changed the values within our pie chart from total sales to the field, total orders to get the total number of orders for each customer segment. The key and Siris are still on customer segment, and then I do the same within my product category sales separate board. So I go back to my product category sales report, and here I also add a static text elements within the summary section off myself report and then I just can't be based my chart and create a new chart to show the total number of orders for each product category. - And I also changed the fuels total sales to total orders within my second chart. Then we safe or sup report and then we re compile the Jerry XML file for product category. Seals sup report again and we go back to our main report and we preview our main reports and run to report again. Then you can see that the two pie charts with sales by customer segment and the orders by customer segments have been added to report. And when we go to the end of our report, then you considered are to bore charts for sales by product category and product. Subcategory and orders by product category and brought except category have both been added to our sup report. But as you can see, the layout off, my separate board has shifted a little bit, so I need to go back to my sup report, and then I'm just going to decrease the size of my column header a little bit. And I'm also going to align my column headers to the left. And when we now re compile our sup report again and we go back to our main reports and preview our report again, then you consider totally out of her columns has been fixed within our sub report. And he can, of course, also see the two charts that we just created within this up report. 13. Building a Java reporting application in Eclipse/NetBeans: So after we've designed our report in Jasper Self Studio, we can start building a chopper reporting application that will generate a report each time we run or application. So before we get started, we first need to install Jesper reports. Jesper reports is a job a library. So you condone to teach our file, which contains all the Java classes from the chest for soft website, Casper reports, is a free and open source library, so you can just download the char file. After that, we're going to embed the chest, reports library within the application blast spot within Eclipse, and we're going to use Eclipse as a job i d. But you can also use, for example, net beans. We also need to add the recommended and required support libraries for Jasper reports to the class spot. So there are some libraries that are required by Jasper reports such as I text or J free chart to create a charts. I'm also Jake Common. So this is an overview of all the required libraries that you might needs to run at. Jesper reports Israel Free libraries. Of course, you have J Free Chart and Jake Common, which are used to create charts within just reports. If you want to export a report to an Excel file, you also need libraries to export two Excel on. But we're not going to use this libraries since we're going to export to a pdf file. So you might need I text, which is a Free Java pdf library. And we also need a J BBC driver and you also need a job development gets to compile your report. An eclipse. So when we opened the Jasper reports for library, you can see that there are many different Colossus. Um, but most importantly, we have teach Asper reports engine, and he just reports Engine contains the most important just for reports classes to compile Phil and export our report to a PdF. So within our job application, we're going to start from our customers. Report Jerrick Smell Foul, which is XML layout off our report. And then we're going to compile this file using the class Jasper compiled manager, and we're going to compile this year. XML file to customers report Jasper file say compiled design file. After that, we're going to use the Jasper Field Manager class, which is also part of the Desperate Reports engine to fill a report from our data source, which is our possibly SQL database. So we're also going to add a JBC connection to our past grass girl database. And after that we're going to export or reports using the Jesper Export Manager class, which is also part of the Jasper Reports engine. We're going to export this report to a customer's report. Pdf file. So within our first exercise, we're going to open our job, i d we're going to open eclipse, and we're going to create a new Java project. And we're also going to add a new job, a source file, which we're going to call report generator about Java. So our job obligation should first compile, are to sign file and then feel the compiled report with data from our data source. So we're going to use the Jasper Feel mansion class to fill our report, then half let her go to export reports to a PdF file, which we want to call customers. Pdf. So we're basically going to use, teach, ask report engine classes to compile Phil and export our report. After that, we're going to add a connection from our job application toe our database. So we're going to create a connection. Using the driver, manager class and connected job application toe are possibly SQL database using a J D B C, which is a Java database Connect driver. As you know, we also have two paramedics within a report, Filter Region and Filter Province. We're going to answer values for the Super Meters from our job application toe a report. So we're going to enable these two pyramids for prompting and then also add these two para meters to our Java application in eclipse. And finally, we're going to compile bills and export or have application to irritable application char fire. So we're basically going to build a job application. It's going to dynamically generate reports using the chess pre force Library. 14. Setting up the Java Libraries in Eclipse/NetBeans: Okay, so next we're going to build an application, a job application it's going to compile and built or PDF customers report. So instead of compiling and running or report in Jesper Self studio, we're now going to run and compile a report from a Java application. So, as you can see, I'm using Eclipse as a job for development environment, and I start by creating a New Java project by going to project and then select Java. I have a project and then I choose a product name, for example. Customers report and I add this project to my default location, which is my clips workspace. I use my existing Java runtime environment and I at my new project. As you can see, Eclipse already creates a source folder and also adds a module which I also call customers report. You can also see that the Java Runtime Environment Systems Library is already at it. But my jesper reports jar files are not at it yet, so I create a new folder, which I call Jasper Reports Library, and within this library, I'm going to add my Jasper reports library files. So I'm going to import files from my file system, select all my jar files and then import these into my project. So, as you can see, all my jar files are now at it within my folder. And I can now also reference these files. I go into properties, then go into a Java built parts and at these shores to my project. And as you can see, the jar files are now add it to my class spot. So now I can actually start creating my first package. So I go to new package and I call this package customers report package. 15. Build a Java Reporting Application to Compile, Fill & Export Reports: Okay, So what, we're going to the next is built a Java class, which we're going to call report generator. So I started by creating a new class file within my package, and I call this report generator. And then I also add a public main methods to my class. Okay, so next time going to import all my class files, So I'm going to start by importing my Jasper reports engine class files, and then I'm going to compile my Jesper report design file and create a new Jasper report, and I'm going to use a Jasper compile manager. And the compile report methods uses a Jasper design file, which is located in my workspace. And this is basically my dear XML, if I which I just designed with Jasper Studio So after I compiled my Jasper report, I can start feeling my report. For now, I'm just going to use an empty data source. So I create a new Jasper report data source, which is a new she are empty data source, which contains 10 empty records. We can also have some print lines form edit, for example. We can add a print sign after we did the completion off our just resign file. And I'm just going to add a simple line Done compiling. Okay, so now we can actually start filling our report. And for this, I'm going to use the chance for film manager. As you can see, feel Report can use a ah, Jesper report file some para meters and also a jr data source. So for now, I'm going to use my Jasper report file Jasper report. I also add my JR data source and I don't add any para meters. Okay, now I can add a new print line present, like in at a print flying to say that I've done ah feeling the Jasper report. So now I'm just going to export this report to a pdf our and I'm going to use the Jasper export manager. And as you can see, you can export report to an HTML file to pdf file or even to an XML. For now, I'm just going to export its report to a pdf. How? And I'm going to use the chance for print objects that we've just created. And once that is done, I can also add a new system print line done exporting the Pdf report, we can also specify the file name of our pdf. How? By using export report pdf file And then we can also specify the name and the part of our export file. So for now, I'm just going to export its file to the customer report workspace. If you now run this job application when we go to the customer report folder within our Jasper workspace and now you can see that the customer report pdf file has been added to the customer report folder within the jaspersoft workspace. 16. Connecting the Java application to a Database (JDBC): what we're going to the next is connect our job application to our pasta SQL database. Um and we're going to use a J BBC connection, which is a Java database connection. And to use this JBC connection, we first need to import our core JBC classes. So I'm going to import my Java JBC classes so that we can create a database connection within or Java application. So let's start by creating a new connection. Come and this connection is going to use my Java bus. Crisco will driver. So I'm going to use driver, manager, get connection and here I can enter my connection string. So I entered the connection string, which is J. D B C plus degree SQL. And then I enter my host name, which, in my case, it's local host. And then I can check my port number by going to my plus Cree SQL database so you can see that my host name is local host and my port number is 5432 and I have a database user which is called Boss Chri s. So I enter my host name local host, and then I enter my port number, which is 54 tree too. Then I enter my database name, which is passed Gree s. I enter my database user, which is also bust. Priess and I enter my database user password and then we can use this connection that we just created when we feel our report. So I'm going to remove the Empty Jr data source because we no need this anymore, and I'm going to replace it. Er data source by our new connection. Come. So what we basically did is we added a new database connection using one of the J. D. B C drivers for prosecute SQL, we entered our host name or port name or database name and also the user and password or database. And then we used this connection to fill a report from our database. So what we can now do is we can re compile and run or application again, and then you can see that the data will be filled with in our report. So let's run our application. And, as you can see now, a new pdf, our customers, pdf, has been created within our Jesper soft workspace. So let's open this pdf file. And if we now open this PDF report, you can see that we get the customers overview for province and region off none of us, which is our default para meter value. And we also get our charts for total seals and total orders by customer segments. And you can also see sup report for product category seals by customer segments. 17. Passing parameters to the Java application (prompting): so as you know, we've added to Para meters to our report. What we're going to the next is enable us to configure these para meters in your job application so that we can specify the values for two filters filter province and filter region from our job application. And after that we're going to enable these pyramids for prompting, which means that we can enter values 40 spare a meters when we run the job application, for example from the command line. So what I'm going to do first is import a new Java class to store the values of my two para meters in a hash map. And this hash map can basically story values off my para meters in a key value pair. So this means that I can store the values in my hash map and also retrieve them later when I want to use the values within my report. So I just imported to the hash map costs, and I'm now going to create a new Java hash map and then I'm going to add to key value pairs to my hash map. So we have our first key value pair for the key filter region, which is the first para meter in a report. Then we can also add a value to despair A meters. I'm going to add a value for one of the regions, for example, Ontario. Then I'm going to add a second key value pair for my second para meter, which is filter province. And I'm also going to add a value for the province, for example, Ontario. So now we've added to key value pairs to our hash map para meters. And to use these two para meters within my report, I just go to the Jasper Feel manager and then we just at the two para meters when we feel the report and if we now we run the application again and we go back to our workspace, you can see that there is a new customers report created. So when we opened this report, then you can see that he knew fielder for province and region Ontario has been added to our customers report. So, as you can see, we've now added a value for the field of problems and feel the region within our job application. We can also enable these perimeters for prompting, which means that we can entry value when we launch the job application to do this. I just at the two pyramid for prompting within my main method. And then I just replace my to default values for filter region in filter province. So what we're going to the next is compile and build this report generator job application . Then we can run this application from the common line, and then we can also enter a value for our filter region and filter province. 18. Run the Java reporting application from the command line: Okay, so next we're going to compile an export. Our report generator to a execute Herbal, Chava jar file. As you can see, my report generator is located in the customers report Project folder. And within the source folder. I have a default package which contains my report generator, and I'm going to export this package to a rentable and execute herbal Java jar application . So I just go to export, and then I select rideable jar file, and then I'm going to save my application within my chest herself, workspace. And I'm also going to include all the required libraries that we've added. I go to finish. And if we now go back to the jesper soft workspace that you concede it, our new report generator jar file has been added to our workspace. And what we're going to the next is run this jar file from the common line. So I opened my command prompt, and I'm going to run this jar file using job. So I just navigate to the location off my java development gets. So as you can see, I'm using job by 11.1 to run this jar file, please also make sure that you're using the same Java version as you did to compile the report generator jar file that I'm just going to execute the char file using the jar comment. And then I just entered the pots and the location off my jar file. Then the name of my jar file is report generator and of course, we need to specify or two para meters because we enabled these para meters for prompting. So I'm going to enter a filter for Region Ontario and also a filter for province. I won't tell you so now I'm passing these two values to my Java application, So we now run our job application. As you can see now our reporters compiled. We also filled our report and exported a new pdf file to the workspace. And when we now go back to the workspace and open the new pdf, our you can see that we get an overview of the customers for province in region Ontario. If we now go back to the common line. And I changed my province in region two, none of it. And I run my job application again. Then you see that we get a new customers, pdf report. And when we open this report, we get all the customers for province in region of none of it. So what we basically did is we created a job application called report Generator and this report generator can generate a pdf report for the customers for a certain province in region. So if you want, you can, of course, also at more para meters to your application or embeds this jar file in another Java application. So I hope you enjoy this course and thank you for watching.