All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.litongjava.mongo.MongoDb Maven / Gradle / Ivy

There is a newer version: 1.4.7
Show newest version
package com.litongjava.mongo;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

public class MongoDb {

  private static MongoClient mongoClient;
  private static MongoDatabase mongoDatabase;

  public static MongoDatabase getDatabase(String databaseName) {
    // 连接到数据库
    MongoDatabase mongoDatabase = mongoClient.getDatabase(databaseName);
    return mongoDatabase;
  }

  public static MongoDatabase getDatabase() {
    return mongoDatabase;
  }

  public static void setClient(MongoClient mongoClient) {
    MongoDb.mongoClient = mongoClient;
  }

  public static void setDatabase(MongoDatabase mongoDatabase) {
    MongoDb.mongoDatabase = mongoDatabase;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy