gpt4 book ai didi

java - 连接 mongolab 上 mongoDB 中的端口

转载 作者:行者123 更新时间:2023-12-02 09:49:09 26 4
gpt4 key购买 nike

我正在尝试连接 mLab,但收到此错误:

03-09 21:13:04.966 21557-21576/? E/AndroidRuntime:  Caused by: java.lang.VerifyError: com/mongodb/DBPort$SaslAuthenticator
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBPort.authenticate(DBPort.java:387)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBPort.checkAuth(DBPort.java:402)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBTCPConnector.doOperation(DBTCPConnector.java:209)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollectionImpl.sendWriteCommandMessage(DBCollectionImpl.java:508)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollectionImpl.writeWithCommandProtocol(DBCollectionImpl.java:458)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollectionImpl.insertWithCommandProtocol(DBCollectionImpl.java:418)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:188)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:167)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollection.insert(DBCollection.java:93)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollection.insert(DBCollection.java:78)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.mongodb.DBCollection.insert(DBCollection.java:120)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.example.irakl_000.maps.server_pcg.ServerRequest$StorePostAsyncTask.doInBackground(ServerRequest.java:161)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at com.example.irakl_000.maps.server_pcg.ServerRequest$StorePostAsyncTask.doInBackground(ServerRequest.java:71)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
03-09 21:13:04.966 21557-21576/? E/AndroidRuntime: at java.lang.Thread.run(Thread.java:841) 

我按照 mLab 的说明进行操作,但出现了问题。这是我的代码:

        final BasicDBObject[] seedData = createSeedData();
MongoClientURI uri = new MongoClientURI("mongodb://<user>:<<password>@ds041861.mlab.com:port/db");
MongoClient client = new MongoClient(uri);
DB db = client.getDB(uri.getDatabase());

DBCollection songs = db.getCollection("texts");

songs.insert(seedData);// HERE IS THE ERROR

我正在使用 mongo-java-driver-2.13.0-rc0.jar 驱动程序。

这是 mLab mLab 的图片

最佳答案

正如我在你的照片中看到的,mLab 使用 mongod 3.0.7。您应该使用 mongo-java-driver-3.x.x。 Here是一个链接

关于java - 连接 mongolab 上 mongoDB 中的端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35900724/

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