UC1: Jaspersoft New Install and New Report Creation
- Kyle Robert L Nelson
Jaspersoft Studio Setup
There are both older and newer versions of Jaspersoft Studio. VetView 3.0 will begin its version lifespan on Jaspersoft 6.18.1 which requires Java11. If you choose to run VetView 2.0, you will want Jaspersoft version 6.11.0 which requires Java7.
Jaspersoft 6.18.1 (VetView 3.0)
https://sourceforge.net/projects/jasperstudio/files/JaspersoftStudio-6.18.1/
Jaspersoft 6.11.0 (VetView 2.2 and older)
https://sourceforge.net/projects/jasperstudio/files/JaspersoftStudio-6.11.0/
Windows users should download the file ending with "windows_x86_64.exe"
Example: TIB_js-studiocomm_6.18.1_windows_x86_64.exe
Mac users should download the file ending with "macosx_x86_64.dmg"
Example: TIB_js-studiocomm_6.18.0_macosx_x86_64.dmg file
Once downloaded, open the file and run the installer.
Data Adapters/Connecting to a Database
*Note: You will need to know your Database localhost url (e.g. 192.168.1.254), the JAR file used for your database, and a username/password you can use to access your database*
This is where we set up our connection to our Database. When opened, you should see something like this in the upper left-hand corner of your Jaspersoft Studio window:
We will then right-click the Data Adapters tab highlighted in blue and select the Create Data Adapter option highlighted in blue:
The following window should appear:
Select Database JDBC Connection, and click Next:
You should now see the following screen which is where we will configure our Database Connection:
Give your connection a Name, then click the drop menu for JDBC Driver, scroll down until you see the “Oracle” option and select it. In the textbox titled “JDBC Url”, replace the “localhost” section highlighted in blue below with your Database url, then also add the username/password with access to your Database:
Next, select Driver Classpath Tab in the bottom-center of your window. Click the Add button, and locate the JAR file used with your database.
Now click the “Test” button to make sure a valid connection to your Database can be established. If the connection test fails, make sure your username/password and Database url are correct, then ensure every other field is configured correctly. Your screen should look something like this:
If the connection test works, hit “Finish”. Your new database connection should now be listed in the top left-hand corner of your screen under the Repository Explorer Tab.
Jaspersoft Studio Overview
JASPERSOFT STUDIO BASICS
Now we will go over the basics of the Jaspersoft Studio screen. After set-up, it should look like this:
Project Explorer View: Displays your projects and associated reports in your MyReports folder.
Repository Explorer: Displays your Data Adapter connections to your Database(s).
Report Editing Area: Working area showing a view of your current report. It has three preview tabs, two of which are editable and one displaying the final preview. Design Editor Tab loads by default.
Design Editor Tab: Displays your report with an overlay allowing you to edit its appearance, drag to align boxes, text boxes for Headers, etc.
Source Editor Tab: Displays your report in raw jrxml code.
Preview Editor Tab: Displays your report in its current form were it to be printed, uploaded for viewing, etc.
Outline View: Displays the pieces of your report seen in the Design Editor Tab in a list format. You can edit various aspects of your report by selecting an object from the list and adjusting its parameters in the Designer Palette and/or Properties View. Objects in this pane include embedded parameters (e.g. date ranges), fields corresponding to columns in the source table(s) of your report, and formatting objects like textboxes (e.g. Title textbox).
Designer Palette: Contains insertable elements such as text fields, images, subreports etc.
Properties View: Allows for aesthetic customization of objects including size, color, font, etc. The target object for customization can be selected either from the Outline View or directly clicked in the Report Editing Area when the Design Editor Tab is active.
Creating New Reports
Reports are saved in two forms, .jrxml and .jasper. The former can be used as a template while the latter is a finalized instance of said template that can be uploaded to VetView. If the template of a report requires changes, it is recommended to save the new .jrxml with a name including a date or other distinguishing convention. For example, if a report is desired that includes an additional parameter or piece of information, saving the .jrxml of this new report while also retaining the original .jrxml allows both forms of the report to be reproduced in the future.
Navigate to File Menu > New > Jasper Report
You should see the following window with a list of templates to choose from:
After selecting a template that suits your needs, a blank report template will appear in your Report Editing Area. The view will use the Design Editor Tab by default. This mode should feel familiar to anyone with experience in InDesign and other creative publishing software.
The next step will be to connect our report template to a dataset. In the top-right section of the Report Editing Area is the Dataset and Query editor dialog button shown below:
This will bring us to our Dataset and Query Dialog window. From here, we can make a Data Adapter (Database) Selection from where our query will gather its results. We can also make a Query Language Selection for our query which will be written in the Query Editor section. Once we’ve written our query, we can click the Read Fields button which will auto-populate our Query’s results’ features which will be displayed in the bottom of the window. From here, we can inspect aspects of our query such as its fields to ensure it encompasses everything intended. The Read Fields button also functions as a quick sanity check as it will throw an error if there are any problems with our query.
Once satisfied with your report, File > Save your .jrxml with a unique name, then click the Compile Report button. This will create a .jasper file with a name matching its .jrxml file name. You can now navigate to the Preview Editor Tab and see a finalized version of your report.
Your report is now ready to be uploaded to VetView!
Uploading to VetView
Select Report Setup from the Navigation menu, then click the Add button:
Fill out the next screen as needed. Make sure the report is marked active and report type is Local Report:
Click the Add button and the following window will appear to the right. Here we will upload the .jrxml and .jasper files we created. Jaspersoft Studio creates a MyReports folder in which it stores report files by default. This folder is typically found in the user’s directory in JaspersoftWorkspace > MyReports. Navigate to this folder to find your .jrxml and .jasper files and upload them to their respective places:
Tutorial: New Report Creation
To bring all the above information together, and practice with some of the features described, we will walkthrough the creation of a new report containing a list of employees’ first names, last names, and usernames.
Start a new report by going to File> New > Jasper Report and choose the Blank_A4 template. For the purposes of this tutorial, we won’t need any of the template design features other than the Title, Detail 1, and Background boxes. Navigate to the Outline View and delete each element by right-clicking and selecting delete until only Title, Detail 1, and Background remain:
Next, click the Dataset and Query editor dialogue button. Make sure you choose a Data Adapter and we will use SQL as our language of choice. Type the following exactly as it appears in the Query Editor, and click the Read Fields button:
Notice the populated fields are the three columns we’ve queried from the Employee table. Click OK to return to the main window. In the Outline View, expand the Fields tab to see the columns from our query. Drag and drop these into the Detail 1 tab. As you do, you should see them appear in the Report Editing Area. These boxes are where their respective values from the Employee table will populate in a list.
Arrange them in the Detail 1 box by dragging them. You can shrink and expand them just as you would a textbox or picture in other programs. The same for the Title and Detail 1 boxes. Arrange them how you would like, ensuring they stay inside the Detail 1 box. Next, do the same with the same Fields and the Title tab in the Outline View. You will see three more boxes appear this time in the Title box. These will not populate the names from our Employee table and are instead the titles for our report data to keep everything organized.
Arrange everything so that the titles are above their corresponding detail boxes. Play with the sizes of the boxes to get the spacing that you would like. Here is how I have mine arranged:
Once you have a layout you are happy with, go to File > Save As.. and save it to your MyReports folder with a unique name. Your .jrxml report template is now saved, and to produce the .jasper file, click the Compile Report button at the top of the Report Editing Area. As a final “sanity check” to make sure everything looks nice and neat with proper spacing, click the Preview tab at the bottom of the Report Editing Area to see your list of employees’ names. If everything looks good, navigate to VetView and follow the steps to upload the .jrxml and .jasper files.
VetView Wiki Most recent releases of VetView: Version 4.2.5 Hotfix (Released 10/31/2024)
To see commonly used terms in VetView Hospital, please visit our Hospital Glossary of Terms.