Question about connecting the Java driver MongoDB

I am using the MongoDB Java driver in a java web application. One question I want to ask is to run Mongo.close () whenever Im makes a request, or I can open it and run other requests and close it when my application is finished.

+5
source share
1 answer

You should be able to run several commands against this single connection.

Some useful information from the documentation .

The Mongo object instance is actually a pool of database connections; you only need one Mongo class object, even with multiple threads.

+7
source

All Articles