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. JasperReports Server also supports Kerberos, 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 TIBCO 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. 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
To enable Kerberos authentication for the data source include the data source and Kerberos user name in the URI. For example:
mongodb://<hostname>:27017/<database>?authMechanism=GSSAPI
| 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 the equivalent SQL terms in parentheses in the descriptions:
| • | 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 with an SQL query 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. 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 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 KeyStore 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 Save dialog appears. |
| 9. | 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. |
| 10. | Click Save in the dialog. The data source appears in the repository. |
Using Kerberos Authentication with MongoDB Data Sources
The native MongoDB driver can connect to MongoDB Enterprise using Kerberos Authentication. Kerberos is a network authentication protocol that allows clients and servers on a non-secure network to use "tickets" to identify themselves.
To use Kerberos authentication, you need to set up the following:
| 1. | Install the Kerberos client tools on the JasperReports Server host. The client tools are included in the JDK/JRE for Windows. Client tools packages are available for Linux and OS X. You will be prompted to enter information on your Kerberos system during the installation. |
| 2. | Download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy files from Oracle and install them on the JasperReports Server. The files are available for download at the Oracle Java SE Downloads page. |
| 3. | Set these Java system properties for JasperReports Server: |
java.security.krb5.realm=<Kerberos_realm>java.security.krb5.kdc=<KDC_server_hostname>javax.security.auth.useSubjectCredsOnly=falsejava.security.auth.login.config=<path>/jaas.conf[/code] |
| 4. | Edit the jaas.conf file to add the following: |
com.sun.security.jgss.krb5.initiate { com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true doNotPrompt=true;};[/code] |
| 5. | Run the kinit mongodb/[mongo-db-hostname]@<Kerberos_realm> command on the JasperReports Server host to create or renew a ticket for the Kerberos user. This is the account you will enter as the user name for the data source. |
Creating a Schema with the Schema Tool
To create a schema with the schema tool:
| 1. | Go to <js-install>/buildomatic/tools 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.