How to Extract SQL Query from Jaspersoft Report or Ad Hoc View
book
Article ID: 130566
calendar_today
Updated On: 07-31-2024
Products
Clarity PPM On Premise
Issue/Introduction
The SQL code behind a Jaspersoft report is requested and there is a need to review the query.
How can the SQL code used by the report be accessed and viewed?
Cause
The stock reports are helpful, however customers may choose to further develop the reports into a customized version.
Resolution
There are 2 methods to extract queries
Method 1 - Advanced Reporting (report folder)
- Before using this method, ensure the user has the Clarity right: Advanced Reporting - Administer
- Go to Home --> Advanced Reporting --> View --> Repository --> Select a report to view. For example, the report(Project Status Report List) is chosen.
- Right click on the Report and click "Export". It will export and display message: Export succeeded.
- Extract the exported file.
- Navigate to the folder: Resources/CA_PPM/reports/project_management to view the related files. The relative path will be displayed
- Under the 'reports' folder, find the file named: main_jrxml.data
- The file can be opened and edited in a text processing editor to view and extract the query.
Method 2 - Advanced Reporting (View Query)
- Login to the Jaspersoft server via the URL
- Go to Manage > Server Settings > Ad Hoc Settings
- Checkmark 'Enable View Query in Ad Hoc Editor. Click 'Change' button to save settings.


Method 3 - Use Jaspersoft Studio
- Create a Jaspersoft Studio connection to the Jaspersoft Server. The steps can be found in our documenation.
- Once a connection to the server is made, expand the tree until the report folder is reached.
- Double-click on the file: Main.jrxml
- Once the report opens, click the icon labeled: "Dataset and Query Editor dialog".

- The Query Editor opens with the report query.
Feedback
Was this article helpful?
thumb_up
Yes
thumb_down
No