连接mongodb数据库
MongoClient client = new MongoClient("192.168.**.**",27017);
MongoCollection<Document> coll = client.getDatabase("库名称").getCollection("表名");
然后直接用就可以了。。。
es:
public static void main(String args[]){
MongoClient client = new MongoClient("192.168.104.64", 27017);
MongoCollection<Document> col = client.getDatabase("school").getCollection("student");
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
Document doc = new Document();
doc.append("_id", uuid);
doc.append("chinses", "中文");
doc.append("english", "this is english!");
col.insertOne(doc);
}
数据库查看结果: