MongoDB is a big data architecture based on the NoSQL model that is neither relational nor SQL-based. We provide connectors that allow reports to use a MongoDB data source or a MongoDB JDBC data source. Reports based on MongoDB data sources can be used as Topics that allow users to create Ad Hoc views based on the fields returned by the MongoDB query. As of version 6.1.1 JasperReports Server also supports SSL and x509 authentication for MongoDB data sources.
As with all big data stores, MongoDB data sources have the following limitations and usage guidelines within JasperReports® Server:
| • | MongoDB data sources are not supported for OLAP connections |
| • | MongoDB data sources can be used in Ad Hoc Topics, but they do not support query optimization. |
| • | You must configure your JVM memory to handle the expected amount of data (see the JasperReports® Server Installation Guide). |
Creating a MongoDB Data Source with the Native MongoDB Driver
| MongoDB data sources do not support virtual data sources when using the native MongoDB driver. For virtual data support, Create a MongoDB JDBC data source. See Creating a MongoDB JDBC Data Source |
To create a MongoDB data source with the native driver:
Follow these steps to create a MongoDB data source with the native MongoDB driver.
| 1. | Log on as an administrator. |
| 2. | Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. Alternatively, you can select Create > Data Source from the main menu on any page and specify a folder location later. If you have installed the sample data, the suggested folder is Data Sources. The New Data Source page appears. |
| 3. | In the Type field, select MongoDB Data Source. The information on the page changes to reflect what’s needed to define a MongoDB data source. |
You have the option to use attributes in the values of data source parameters. See Attributes in Data Source Definitions.
|
MongoDB Data Source Page |
| 4. | Fill in the required fields, along with any optional information. |
The MongoDB URI has the form: mongodb://<hostname>:27017/<database>
To enable SSL include the argument "ssl=true" in the URI. For example:
mongodb://<hostname>:27017/<database>?ssl=true
To enable x509 authentication for the data source include it as well in the URI. For example:
mongodb://<hostname>:27017/<database>?ssl=true&authMechanism=MONGODB-X509
| Before you can enable x509 authentication you need to set up the Java Secure Socket Extension (JSSE) in your application server. |
| 5. | Click Test Connection to validate the data source. |
| 6. | When the test is successful, click Save. The Save dialog appears. |
| 7. | Enter a name for the data source and an optional description. The Resource ID is generated from the name you enter. If you haven't already specified a location, expand the folder tree and select the location for your data source. |
| 8. | Click Save in the dialog. The data source appears in the repository. |
The Jaspersoft MongoDB Query Language
MongoDB is designed to be accessed through API calls in an application or a command shell. As a consequence, it does not have a defined query language. In order to write queries for MongoDB data sources, we have developed a query language based on the JSON-like objects upon which MongoDB operates. JSON is the JavaScript Object Notation, a textual representation of data structures that is both human- and machine-readable.
The Jaspersoft® MongoDB Query Language is a declarative language for specifying what data to retrieve from MongoDB. The connector converts this query into the appropriate API calls and uses the MongoDB Java connector to query the MongoDB instance. The following examples give an overview of the Jaspersoft MongoDB Query Language, with SQL-equivalent terms in parentheses:
| • | Retrieve all documents (rows) in the given collection (table): |
| • | From all documents in the given collection, select the named fields (columns) and sort the results: |
| • | Retrieve only the documents (rows) in the given collection (table) that match the query (where clause). In this case, the date is greater-than-or-equal to the input parameter, and the name matches a string (starts with N): |
The Jaspersoft® MongoDB Query Language also supports advanced features of MongoDB such as map-reduce functions and aggregation that are beyond the scope of this document. For more information, see the language reference on the Community website.
Creating a MongoDB JDBC Data Source
If you want to use your MongoDB data source in a domain or virtual data source, create a MongoDB JDBC data source. The MongoDB JDBC driver can create a default normalized schema for your data or, if you prefer, you can load a schema from the repository or your server file system.
To create a MongoDB JDBC data source:
| 1. | Log on as an administrator. |
| 2. | Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. Alternatively, you can select Create > Data Source from the main menu on any page and specify a folder location later. If you have installed the sample data, the suggested folder is Data Sources. The New Data Source page appears. |
| 3. | In the Type field, select MongoDB JDBC Data Source. The information on the page changes to reflect what’s needed to define a MongoDB JDBC data source. |
You have the option to use attributes in the values of data source parameters. See Attributes in Data Source Definitions.
|
MongoDB JDBC Data Source Page |
| 4. | Fill in the required fields, along with any optional information. |
| 5. | Specify your Connection Options. For example, if you're using MongoDB 3.0 and you want to enable SSL, enter: |
EncryptionMethod=SSL;ValidateServerCertificate=false
To enable both SSL encryption and self-signed CA, enter the TrustStore and KeyStore paths and the KyStore password. For example:
EncryptionMethod=SSL;TrustStore=<path>;KeyStore=<path>;KeyStorePassword=<password>;
The Auto Generate Schema Definition check box is checked by default. With this option selected, When you first connect to a MongoDB server, the driver automatically creates a normalized schema of the data and generates a SchemaDefinition for housing and sharing the normalized schema.
| 6. | To specify a schema you've created, uncheck this box and: |
| b. | If your file is in the repository, click the Browse button and locate it in the repository. If your file is in your server file system, enter the path in the Server File Location text box. To upload a schema to the repository, see Uploading a Schema to the Repository |
| 7. | Click Test Connection to validate the data source. |
| 8. | When the test is successful, click Save. The data source appears in the repository. |
Creating a Schema with the Schema Tool
To create a schema with the schema tool:
| 1. | Go to buildomatictools and double click the schematool.jar file. |
| 2. | Follow the instructions in the schema tool documentation found here: |
https://documentation.progress.com/output/DataDirect/jdbcmongohelp/index.html#page/mongohelp/starting-the-schema-tool.html
Uploading a Schema to the Repository
To upload a schema to the repository:
| 1. | Click View > Repository and expand the folder tree. |
| 2. | Right-click a folder and select Add Resource > File > MongoDB JDBC Schema from the context menu. |
| 3. | Use the Upload File From Your Local Computer page to locate and upload your schema file. |
Recommended Comments
There are no comments to display.