使用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});
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});
相关文章推荐
- OSCache的源码编译Cache.java 文件报add(Class, T) in the type EventListenerList is not applicable for the arguments 错误的解决
- 报错:The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the ar
- 错误:The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the argum
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable
- The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the argum
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable
- 使用myeclipse开发java,解决java中继承JFrame类出现The type JFrame is not accessible due to restriction的问题
- android 的The method makeText(Context, CharSequence, int) in the type Toast is not applicable fo(
- The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV
- he method get(Class, Serializable) in the type HibernateTemplate is not applicable for the arguments
- The method setOnKeyListener(View.OnKeyListener) in the type View is not applicable for the argum
- 提示错误:The method replace in the type.. is not applicable for the argument......
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the argum
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the argum
- Android Error - The method replace(int, Fragment) in the type FragmentTransaction is not applicable
- The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the ar
- The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the argum
- The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments