开发者

Java MongoDB Driver Connection Question

开发者 https://www.devze.com 2023-01-22 11:25 出处:网络
Im using the MongoDB Java driver in a java web app. One question I want to ask is do i run Mongo.close() whenever Im doing doing a query , or can I开发者_高级运维 keep it open and run other queries on

Im using the MongoDB Java driver in a java web app. One question I want to ask is do i run Mongo.close() whenever Im doing doing a query , or can I开发者_高级运维 keep it open and run other queries on it and close it when my application ends.


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

Some useful details from the documentation.

The Mongo object instance actually represents a pool of connections to the database; you will only need one object of class Mongo even with multiple threads.

0

精彩评论

暂无评论...
验证码 换一张
取 消