gpt4 book ai didi

java - 在java中使用mongodb时出错

转载 作者:行者123 更新时间:2023-12-02 07:44:29 27 4
gpt4 key购买 nike

我正在使用 MongoDB 来存储数据。在我的项目中,我使用线程池将多个用户(100-2000 个用户)连接到服务器,并将这些用户的响应存储在数据库中。但是当我这样做时,我收到了这个错误。请在这件事上给予我帮助。我无法得到它。我已经在这个错误上浪费了 45 个小时。

错误:

java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.avaya.onex.hss.requesthandlers.CommandExecutor.executeCommands(CommandExecutor.java:129)
at com.avaya.onex.hss.requesthandlers.CommandExecutor.run(CommandExecutor.java:59)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection
at com.mongodb.DBPortPool.get(DBPortPool.java:176)
at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:370)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:149)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:138)
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:261)
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:211)
at com.mongodb.DBCollection.insert(DBCollection.java:57)
at com.mongodb.DBCollection.insert(DBCollection.java:102)
at com.avaya.onex.hss.objects.LoginRequest.storeData(LoginRequest.java:152)
at com.avaya.onex.hss.requesthandlers.LoginHandler.handleRequest(LoginHandler.java:20)
... 8 more
com.mongodb.DBPortPool$SemaphoresOut: Out of semaphores to get db connection
at com.mongodb.DBPortPool.get(DBPortPool.java:176)
at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:370)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:212)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
at com.mongodb.DB.command(DB.java:160)
at com.mongodb.DB.command(DB.java:183)
at com.mongodb.DB.command(DB.java:144)
at com.mongodb.DBCollection.drop(DBCollection.java:777)
at com.mongodb.DBApiLayer$MyCollection.drop(DBApiLayer.java:206)
at com.avaya.onex.hss.requesthandlers.CommandExecutor.executeCommands(CommandExecutor.java:118)
at com.avaya.onex.hss.requesthandlers.CommandExecutor.run(CommandExecutor.java:59)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

最佳答案

尝试增加连接池中的连接数。

here ,在connectionsPerHost处。

关于java - 在java中使用mongodb时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11081450/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com