Sneak Peek at the Upcoming MongoDB ODA

Soon after the MongoDB noSQL-style database system started becoming popular, the BIRT community started asking for ways to get at that data. The good news for developers using BIRT, is that BIRT was designed with data source extensibility in mind. There are several ways to connect to MongoDB as a data source within BIRT. This post will show how to connect to MongoDB with your existing BIRT version, plus several screenshots from the new MongoDB ODA driver being added to the next major release of BIRT due out this summer.

BIRT Scripted Data Source Connection to MongoDB

The BIRT Scripted Data Source is like the ‘silver-bullet’ into any data source. If you cannot connect to your data with one of the built-in BIRT data sources, then the Scripted Data Source may be the answer. It uses the server-side RHINO Javascript engine allowing you to write a bit of Java or Javascript as a simple wrapper to your data. As long as you can get to your data in your application, then it’s likely the Scripted Data Source can get that data into BIRT.

To create a connection to MongoDB, you first need to add the MongoDB JAR to your project classpath. Now, you just add a bit of Javascript to the following methods to make it work.

Create connection and query in the open method

m = new Mongo( "localhost" , 27017 );
db = m.getDB( "scratch" );
col = db.getCollection("zips");

query = new BasicDBObject();
query.put("state", "AL");
cursor = col.find(query);

The fetch method will get called repeatedly while you return true
if( cursor.hasNext() ){
var jsonStr = new String(;
row["city"] = jsonStr.split(",")[1].split(":")[1].replace("\"", "");
row["zip"] = jsonStr.split(",")[2].split(":")[1].replace("\"", "");
row["state"] = jsonStr.split(",")[6].split(":")[1].replace("\"", "").replace("}","");
return true;
return false;

The close method is used to discard objects

Community Created BIRT Plug-Ins for MongoDB

Part of BIRT’s extensibility allows for external plug-ins to be dropped into existing versions of BIRT. There have been several community developed BIRT plug-ins to access MongoDB data created over the years. At the time of this post, a quick search in the BIRT Exchange DevShare shows 3 different MongoDB ODA Driver plug-ins to choose from.

Different Plug-ins

New MongoDB ODA Driver for BIRT

The next major release of BIRT will include a new data driver for accessing MongoDB. This means, instead of creating your own connection to MongoDB in a scripted data set, you can now simply select MongoDB from a list of available choices.

Select MongoDB

Next, fill out the database credentials and connection information. This information can be hard-coded in each specific field or the connection information can be dynamically generated at runtime using BIRT’s Property Binding feature.

Database Credentials

Once you have created a connection, you can now create a new Data Set to query for specific data. BIRT supports the MongoDB operations that return data. This includes the Query commands, the Aggregate command, MapReduce, and select Database Commands that return data.

Creating a MongoDB Data Set in BIRT

Creating DataSet

The new MongoDB Data Set dialog allows you to choose the data Collection and fields you want returned from the query. Java Objects can be flatted out to bring in just the data elements, or the entire object can be brought back for further processing. Select Finish and we can now preview the results of the MongoDB query.

Preview Results

Using a MongoDB MapReduce Command in BIRT

MapReduce Command

Using a MongoDB Aggregate Command in BIRT

Aggregate Command

Using a MongoDB Database Command in BIRT

Database Command

BIRT supports a subset of the MongoDB Database Commands that return data. The following is a list of the supported database commands from within BIRT.

buildInfo, collStats, connPoolStats, count, cursorInfo, dataSize, dbStats, distinct, eval with nolock: true geoNear, geoSearch, getLastError, getLog, getPrevError, group, isMaster, isdbgrid, listCommands, listDatabases, listShards, ping, printShardingStatus, replSetGetStatus, serverStatus


There are several ways to connect to MongoDB no matter what version you are using. The new MongoDB ODA driver will make it’s first appearance in BIRT version 4.3 Milestone 7 due out soon.

About the Author
Virgil Dodson

Virgil Dodson