读书人

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

发布时间: 2013-09-26 10:32:35 作者: rapoo

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();
}

}
}

?

读书人网 >其他数据库

热点推荐