您的位置:首页 > 数据库 > Mongodb

使用JAVA向MongoDB中插入数据时报错The method insert(DBObject[]) in the type DBCollection is not applicable

2017-10-25 17:57 811 查看
MONGODB JAVA驱动API文档地址:
http://mongodb.github.io/mongo-java-driver/3.4/javadoc/
DBCollection users = db.getCollection("users");   

BasicDBObject user1=new BasicDBObject("name","zj").append("sex","male").append("age","24").append("address",new BasicDBObject("street","chaoyangzhonglu").append("number", "666"));
users.insert(user1);

报错The method insert(DBObject[]) in the type DBCollection is not applicable for the arguments (BasicDBObject)

方法:

1.修改JAVA project的java compiler 为1.5以上

2.users.insert(new DBObject[] {user1});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐