Possible to setup a DB connection with MongoDB

+1 vote
asked Nov 13, 2020 by bryan-b-6726 (210 points)
Has anyone had any success setting up a Global DB Connection to a mongoDB instance?

1 Answer

+3 votes
Best answer

MongoDB is a noSQL or document database.  QIE's database connections are based on SQL and using a standard JDBC driver for connecting to the SQL server.  Because of this, you can't connect to the MongoDB database using the QIE database connection configuration.

To connect to MongoDB using QIE, you would first need to download the drivers and place them in the libs directory so that the classes become avaible to the QIE service.   This can be done by following these steps

Once you have the drivers installed, you will need to write a custom script that manually creates a new connection object, and then uses it to query the database using the noSQL options available from the driver itself.

Doing a search for the MongDB JDBC driver does show that there are some options that might work.  Many of them require you to purchase the driver, and other don't.  I can't speak to the usability or relyability of those drivers.

Here is an example of how you would connect to "testEMR" MongoDB and then get the values from the Patient collection:

var mongoClient = new com.mongodb.MongoClient();
var database = mongoClient.getDatabase("testEMR");
var mongoCollection = database.getCollection("Patient");

var collectionArray = mongoCollection.find().iterator();
while (collectionArray.hasNext()) {
   var doc =;

answered Nov 13, 2020 by ben-s-7515 (11,100 points)
selected Nov 13, 2020 by bryan-b-6726