@Immutable public interface MongoClient extends java.io.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(java.lang.String name)
Gets the database with the given name.
|
com.mongodb.async.client.MongoClientSettings |
getSettings()
Deprecated.
this method is being removed
|
org.reactivestreams.Publisher<java.lang.String> |
listDatabaseNames()
Get a list of the database names
|
org.reactivestreams.Publisher<java.lang.String> |
listDatabaseNames(ClientSession clientSession)
Get a list of the database names
|
ListDatabasesPublisher<Document> |
listDatabases()
Gets the list of databases
|
<TResult> ListDatabasesPublisher<TResult> |
listDatabases(java.lang.Class<TResult> clazz)
Gets the list of databases
|
ListDatabasesPublisher<Document> |
listDatabases(ClientSession clientSession)
Gets the list of databases
|
<TResult> ListDatabasesPublisher<TResult> |
listDatabases(ClientSession clientSession,
java.lang.Class<TResult> clazz)
Gets the list of databases
|
org.reactivestreams.Publisher<ClientSession> |
startSession(ClientSessionOptions options)
Creates a client session.
|
MongoDatabase getDatabase(java.lang.String name)
name
- the name of the databasevoid close()
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
@Deprecated com.mongodb.async.client.MongoClientSettings getSettings()
Note: MongoClientSettings
is immutable.
org.reactivestreams.Publisher<java.lang.String> listDatabaseNames()
org.reactivestreams.Publisher<java.lang.String> listDatabaseNames(ClientSession clientSession)
clientSession
- the client session with which to associate this operationListDatabasesPublisher<Document> listDatabases()
<TResult> ListDatabasesPublisher<TResult> listDatabases(java.lang.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, java.lang.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 toorg.reactivestreams.Publisher<ClientSession> startSession(ClientSessionOptions options)
options
- the options for the client session