当前位置:   article > 正文

java mongodb helper_我用java连接mongodb抛出错,见过??。。

org.bson.bsoninvalidoperationexception: value expected to be of type documen

我用java连接mongodb抛出错,见过??。。

茶什i

45e3020af9af1140b1017f2205d095cc.png2020-04-01 14:06:45

public static void main(String[] args) { // Mongo m = new Mongo(); DB db = MongoUtils.getDB("test") ; DBCollection coll = db.getCollection("mycollection") ; DBObject documents = new BasicDBObject(); documents.put("name", "abc") ; documents.put("age", 24) ; coll.insert(documents) ; }之后抛出此错误:com.mongodb.MongoException: org.bson.BsonInvalidOperationException: Document does not contain key versionArray at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:112) at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127) at java.lang.Thread.run(Thread.java:745)Caused by: org.bson.BsonInvalidOperationException: Document does not contain key versionArray at org.bson.BsonDocument.throwIfKeyAbsent(BsonDocument.java:757) at org.bson.BsonDocument.getArray(BsonDocument.java:140) at com.mongodb.connection.DescriptionHelper.getVersion(DescriptionHelper.java:106) at com.mongodb.connection.DescriptionHelper.createConnectionDescription(DescriptionHelper.java:56) at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:85) at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43) at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:98) ... 2 more

分享到

pHry8fJ+foRzMQHAAAAABJRU5ErkJgggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/140808?site
推荐阅读
相关标签
  

闽ICP备14008679号