Do I need to explicitly close connection?

前端 未结 2 887
猫巷女王i
猫巷女王i 2020-12-03 20:58

I\'m holding one instance of MongoClient and DB in my application, and every time that I want to execute some operation I call getCollection(

2条回答
  •  借酒劲吻你
    2020-12-03 21:18

    No, you do not need to close connections to DB - your only connection is via MongoClient and as the documentation states - it handles connection pooling for you.

    The only resource that you would want to clean up would be a cursor which you should close() when you're done with it.

提交回复
热议问题