@Immutable public interface MongoClient extends java.io.Closeable
Instance of this class serve 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.
|
MongoClientSettings |
getSettings()
Gets the settings that this client uses to connect to server.
|
MongoIterable<java.lang.String> |
listDatabaseNames()
Get a list of the database names
|
ListDatabasesIterable<Document> |
listDatabases()
Gets the list of databases
|
<TResult> ListDatabasesIterable<TResult> |
listDatabases(java.lang.Class<TResult> resultClass)
Gets the list of databases
|
MongoDatabase getDatabase(java.lang.String name)
name
- the name of the databasejava.lang.IllegalArgumentException
- if databaseName is invalidMongoNamespace.checkDatabaseNameValidity(String)
void close()
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
MongoClientSettings getSettings()
Note: MongoClientSettings
is immutable.
MongoIterable<java.lang.String> listDatabaseNames()
ListDatabasesIterable<Document> listDatabases()
<TResult> ListDatabasesIterable<TResult> listDatabases(java.lang.Class<TResult> resultClass)
TResult
- the type of the class to use instead of Document
.resultClass
- the class to cast the database documents to