@Immutable public interface MongoClient extends Closeable
 Instance of this class server as factories for MongoDatabase instances.
 
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()
Close the client, which will close all underlying cached resources, including, for example,
 sockets and background monitoring threads. 
 | 
MongoDatabase | 
getDatabase(String name)
Gets the database with the given name. 
 | 
MongoClientSettings | 
getSettings()
Deprecated. 
 
this method is being removed 
 | 
org.reactivestreams.Publisher<String> | 
listDatabaseNames()
Get a list of the database names 
 | 
org.reactivestreams.Publisher<String> | 
listDatabaseNames(ClientSession clientSession)
Get a list of the database names 
 | 
ListDatabasesPublisher<Document> | 
listDatabases()
Gets the list of databases 
 | 
<TResult> ListDatabasesPublisher<TResult> | 
listDatabases(Class<TResult> clazz)
Gets the list of databases 
 | 
ListDatabasesPublisher<Document> | 
listDatabases(ClientSession clientSession)
Gets the list of databases 
 | 
<TResult> ListDatabasesPublisher<TResult> | 
listDatabases(ClientSession clientSession,
             Class<TResult> clazz)
Gets the list of databases 
 | 
org.reactivestreams.Publisher<ClientSession> | 
startSession()
Creates a client session. 
 | 
org.reactivestreams.Publisher<ClientSession> | 
startSession(ClientSessionOptions options)
Creates a client session. 
 | 
ChangeStreamPublisher<Document> | 
watch()
Creates a change stream for this client. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(Class<TResult> resultClass)
Creates a change stream for this client. 
 | 
ChangeStreamPublisher<Document> | 
watch(ClientSession clientSession)
Creates a change stream for this client. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(ClientSession clientSession,
     Class<TResult> resultClass)
Creates a change stream for this client. 
 | 
ChangeStreamPublisher<Document> | 
watch(ClientSession clientSession,
     List<? extends Bson> pipeline)
Creates a change stream for this client. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(ClientSession clientSession,
     List<? extends Bson> pipeline,
     Class<TResult> resultClass)
Creates a change stream for this client. 
 | 
ChangeStreamPublisher<Document> | 
watch(List<? extends Bson> pipeline)
Creates a change stream for this client. 
 | 
<TResult> ChangeStreamPublisher<TResult> | 
watch(List<? extends Bson> pipeline,
     Class<TResult> resultClass)
Creates a change stream for this client. 
 | 
MongoDatabase getDatabase(String name)
name - the name of the databasevoid close()
close in interface AutoCloseableclose in interface Closeable@Deprecated MongoClientSettings getSettings()
Note: MongoClientSettings is immutable.
org.reactivestreams.Publisher<String> listDatabaseNames()
org.reactivestreams.Publisher<String> listDatabaseNames(ClientSession clientSession)
clientSession - the client session with which to associate this operationListDatabasesPublisher<Document> listDatabases()
<TResult> ListDatabasesPublisher<TResult> listDatabases(Class<TResult> clazz)
TResult - the type of the class to use instead of Document.clazz - the class to cast the database documents toListDatabasesPublisher<Document> listDatabases(ClientSession clientSession)
clientSession - the client session with which to associate this operation<TResult> ListDatabasesPublisher<TResult> listDatabases(ClientSession clientSession, Class<TResult> clazz)
TResult - the type of the class to use instead of Document.clientSession - the client session with which to associate this operationclazz - the class to cast the database documents toChangeStreamPublisher<Document> watch()
<TResult> ChangeStreamPublisher<TResult> watch(Class<TResult> resultClass)
TResult - the target document type of the iterable.resultClass - the class to decode each document intoChangeStreamPublisher<Document> watch(List<? extends Bson> pipeline)
pipeline - the aggregation pipeline to apply to the change stream.<TResult> ChangeStreamPublisher<TResult> watch(List<? extends Bson> pipeline, Class<TResult> resultClass)
TResult - the target document type of the iterable.pipeline - the aggregation pipeline to apply to the change streamresultClass - the class to decode each document intoChangeStreamPublisher<Document> watch(ClientSession clientSession)
clientSession - the client session with which to associate this operation<TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, Class<TResult> resultClass)
TResult - the target document type of the iterable.clientSession - the client session with which to associate this operationresultClass - the class to decode each document intoChangeStreamPublisher<Document> watch(ClientSession clientSession, List<? extends Bson> pipeline)
clientSession - the client session with which to associate this operationpipeline - the aggregation pipeline to apply to the change stream.<TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, List<? extends Bson> pipeline, Class<TResult> resultClass)
TResult - the target document type of the iterable.clientSession - the client session with which to associate this operationpipeline - the aggregation pipeline to apply to the change streamresultClass - the class to decode each document intoorg.reactivestreams.Publisher<ClientSession> startSession()
org.reactivestreams.Publisher<ClientSession> startSession(ClientSessionOptions options)
options - the options for the client session