最近我发现,我在我的MySQL数据库连接过多: mysql> show status like 'Conn%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 39 |
+---------------+-------+
1 row in set
我使用MongoDbFactory通过Java连接到mongodb。但是mongo服务每小时至少抛出一次socket异常。因此我被迫重启mongodb服务来恢复操作。我认为这可能是由于java关闭了mongodb的连接,MongoDbFactory也没有提供关闭连接的功能。我如何确保所有连接在特定会话后关闭。 这是我使用的代码:我遇到的问题与Mongo对象以及 private String ins