zoukankan      html  css  js  c++  java
  • Mongo的基本操作

     

     

     package com.mongo;import java.util.ArrayList;import java.util.List;import org.bson.Document;import com.mongodb.MongoClient;import com.mongodb.client.MongoCollection;import com.mongodb.client.MongoDatabase;
    public class MongoTest {
       public static void main(String[] args) {
           MongoClient mongoClient = new MongoClient("localhost", 27017);
           MongoDatabase mongoDatabase = mongoClient.getDatabase("student");
           MongoCollection<Document> collection = mongoDatabase
                   .getCollection("student");
           Document document = new Document("name", "scofield").append(
                   "score",
                   new Document("English", 45).append("Math", 89).append(
                           "Computer", 100));
           List<Document> documents = new ArrayList<Document>();
           documents.add(document);
           collection.insertMany(documents);
           System.out.println("文档插入成功");
       }}
  • 相关阅读:
    html例题——简历
    求值
    c#语句实例(排大小)
    3.6语言基础笔记
    2016.3.5进制间的转换
    3.26-1
    3.23(网页)
    3.23
    3.22
    3.20
  • 原文地址:https://www.cnblogs.com/yizhixiaozhu/p/14211853.html
Copyright © 2011-2022 走看看