Jump to content
Changes to the Jaspersoft community edition download ×
  • 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

    1. Add a new datasource of type "MongoDB Connection"

      03_Add_Data_Source_iR_MongoDB.png.4a700413f8f9b55e4c582b3d8e317d6b.png

    1. Set an appropriate url and test the connection

      04_Data_Source_Properties_iR_MongoDB.png.8f14963288907ea6dd357e45d1fc9eda.png

    3. Create a report

    The simplest way for a new user to create a new report is with the Report Wizard.

    1. File → New...
    2. Choose any template and click "Launch Report Wizard".
    3. Set the report name and location.
    4. Create a query to retrieve data.
      1. There is no visual query editor, so the button "Design query" is inactive.
      2. The Jaspersoft query language for MongoDB is documented here:

        Jaspersoft MongoDB Query Language

    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

    1. Copy the files in WEB-INF from step 1 into /webapps/jasperserver-pro/WEB-INF

    2. Be sure to keep the folder structure when copying the files.
    3. Start or restart JasperReports Server.

    5. Deploy the report to JasperReports Server

    Create the Data Source

    1. Define the data source in JasperReports Server

      Right-click a folder, add a Data Source

      05_Add_Data_Source_JRS.png.d5b5af425b182791058490f6a56503e2.png
    2. Set the Data Source properties

      06_Data_Source_Properties_JRS_MongoDB.png.a17f6f0026d41ec54b0aa71ef72e28ea.png

    Create and Run the Report

    1. Use either the JasperReports Server web interface or the iReport Repository Navigator to deploy the report.

      Deploying from iReport is simpler in most cases.

    2. Run the report

      Search for the report or browse to the report in the JasperReports Server repository.

    Related Links


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...