public final class MongoClients extends Object
Modifier and Type | Method and Description |
---|---|
static MongoClient |
create()
Creates a new client with the default connection string "mongodb://localhost".
|
static MongoClient |
create(com.mongodb.ConnectionString connectionString)
Create a new client with the given connection string.
|
static MongoClient |
create(com.mongodb.ConnectionString connectionString,
com.mongodb.client.MongoDriverInformation mongoDriverInformation)
Create a new client with the given connection string.
|
static MongoClient |
create(com.mongodb.async.client.MongoClient asyncMongoClient)
Creates a new client with the given async MongoClient.
|
static MongoClient |
create(com.mongodb.async.client.MongoClientSettings settings)
Create a new client with the given client settings.
|
static MongoClient |
create(com.mongodb.async.client.MongoClientSettings settings,
com.mongodb.client.MongoDriverInformation mongoDriverInformation)
Creates a new client with the given client settings.
|
static MongoClient |
create(String connectionString)
Create a new client with the given connection string.
|
static org.bson.codecs.configuration.CodecRegistry |
getDefaultCodecRegistry()
Gets the default codec registry.
|
public static MongoClient create()
public static MongoClient create(com.mongodb.async.client.MongoClientSettings settings)
settings
- the settingspublic static MongoClient create(String connectionString)
connectionString
- the connectionpublic static MongoClient create(com.mongodb.ConnectionString connectionString)
connectionString
- the settingspublic static MongoClient create(com.mongodb.ConnectionString connectionString, com.mongodb.client.MongoDriverInformation mongoDriverInformation)
Note: Intended for driver and library authors to associate extra driver metadata with the connections.
connectionString
- the settingsmongoDriverInformation
- any driver information to associate with the MongoClientpublic static MongoClient create(com.mongodb.async.client.MongoClientSettings settings, com.mongodb.client.MongoDriverInformation mongoDriverInformation)
Note: Intended for driver and library authors to associate extra driver metadata with the connections.
settings
- the settingsmongoDriverInformation
- any driver information to associate with the MongoClientpublic static MongoClient create(com.mongodb.async.client.MongoClient asyncMongoClient)
Note: This shares the MongoClient
between two APIs. Calling close from either API will close the client.
asyncMongoClient
- the async MongoClientpublic static org.bson.codecs.configuration.CodecRegistry getDefaultCodecRegistry()
MongoClientSettings.getCodecRegistry()