The Jaspersoft MongoDB Connector
The Jaspersoft MongoDB Connector works with iReport, JasperReports, and JasperReports Server. In previous versions (4.7 and below) the MongoDB driver needed to be installed seprately, you can find instructions on installation for older versions are here: MongoDB Install
Target Audience
Users who want to integrate Jaspersoft's JasperReports Server with MongoDB. This document assumes that the user already has familiarity with MongoDB and already has data in MongoDB collections.
Getting Started
- Add a new datasource of type "MongoDB Connection"
- Set an appropriate url and test the connection
3. Create a report
The simplest way for a new user to create a new report is with the Report Wizard.
- File → New...
- Choose any template and click "Launch Report Wizard".
- Set the report name and location.
- Create a query to retrieve data.
- There is no visual query editor, so the button "Design query" is inactive.
The Jaspersoft query language for MongoDB is documented here:
Sample queries
Minimal:
{ 'collectionName' : 'accounts' }
Specify the fields returned and sort the results:
{ 'collectionName' : 'accounts', 'findFields' : {'name':1,'phone_office':1,'billing_address_city':1,'billing_address_street':1,'billing_address_country':1}, 'sort' : {'billing_address_country':-1,'billing_address_city':1} }
Filtered and parameterized:
{ 'collectionName' : 'accounts', 'findQuery' : { 'status_date' : { '$gte' : $P{StartDate} }, 'name' : { '$regex' : '^N', '$options' : '' } } }
MapReduce job:
{ 'collectionName' : 'zips', 'sort' : { 'value.population' : -1, }, 'mapReduce' : { 'map' : 'function () { emit (this.state, {population : this.pop}); }', 'reduce' : 'function (key, values) { var total = 0; for( var index = 0; index < values.length; index ++) { total += valuesindex.population; } return {population : total} }', 'out' : 'totalPopulation' } }
4. Deploy the query executer to JasperReports Server
Import note: These steps are only required if you have JasperReports Server version 4.5.1 or below
Copy the files in WEB-INF from step 1 into
/webapps/jasperserver-pro/WEB-INF - Be sure to keep the folder structure when copying the files.
- Start or restart JasperReports Server.
5. Deploy the report to JasperReports Server
Create the Data Source
Define the data source in JasperReports Server
Right-click a folder, add a Data Source
Set the Data Source properties
Create and Run the Report
Use either the JasperReports Server web interface or the iReport Repository Navigator to deploy the report.
Deploying from iReport is simpler in most cases.
Run the report
Search for the report or browse to the report in the JasperReports Server repository.
Related Links
- Read the query reference
- Download JasperReports Server: Community Edition or Commercial Edition.
- Download the Jaspersoft MongoDB Connector.
- MongoDB Resources
- MongoDB Website: http://www.mongodb.org/
- MongoDB Documentation: http://docs.mongodb.org/manual/
- MongoDB Training: http://education.mongodb.org
- The Jaspersoft MongoDB Query Language
- Geospatial Queries Example
Log in or register to post comments