使用 org.springframework.data.mongodb.core.MongoTemplate
似乎 MongoDB 驱动程序无法从池中的连接中删除丢弃的套接字,直到您的代码尝试使用它
错误如下:
2013-9-2 9:13:16 com.mongodb.DBPortPool gotError
警告: emptying DBPortPool to /IP:27017 b/c of error
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at org.bson.io.PoolOutputBuffer.pipe(PoolOutputBuffer.java:129)
at com.mongodb.OutMessage.pipe(OutMessage.java:236)
at com.mongodb.DBPort.go(DBPort.java:133)
at com.mongodb.DBPort.call(DBPort.java:92)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:244)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273)
at com.mongodb.DBCursor._check(DBCursor.java:368)
at com.mongodb.DBCursor._hasNext(DBCursor.java:459)
at com.mongodb.DBCursor.hasNext(DBCursor.java:484)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1530)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1336)
在数据库 DB 上对服务器 /IP:27017 的读取操作失败;嵌套异常是 com.mongodb.MongoException$Network: 对服务器 /IP:27017 的读取操作在数据库 DB 上失败
除了try catch还有其他解决方案吗?