首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Java 去 MongoDB 插入文档的几种方法

2013-09-26 
Java 往 MongoDB 插入文档的几种方法detail : {records : 99, index : vps_index1, active :

Java 往 MongoDB 插入文档的几种方法
"'detail' : {'records' : 99, 'index' : 'vps_index1', 'active' : 'true'}}}";

DBObject dbObject = (DBObject)JSON.parse(json);

collection.insert(dbObject);

DBCursor cursorDocJSON = collection.find();
while (cursorDocJSON.hasNext()) {
System.out.println(cursorDocJSON.next());
}

collection.remove(new BasicDBObject());

} catch (UnknownHostException e) {
e.printStackTrace();
} catch (MongoException e) {
e.printStackTrace();
}

}
}

?

热点排行