Java com.mongodb MongoClient fields, constructors, methods, implement or subclass

Example usage for Java com.mongodb MongoClient fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for com.mongodb MongoClient.

The text is from its open source code.

Subclass

com.mongodb.MongoClient has subclasses.
Click this link to see all its subclasses.

Implementation

com.mongodb.MongoClient has the following implementations.
Click this link to see all its implementation.

Constructor

MongoClient(final String host, final MongoClientOptions options)
Creates a Mongo instance based on a (single) mongodb node (default port).
MongoClient(final String host, final int port)
Creates a Mongo instance based on a (single) mongodb node.
MongoClient(final ServerAddress addr, final List credentialsList)
Creates a Mongo instance based on a (single) mongodb node and a list of credentials
MongoClient(final ServerAddress addr, final MongoClientOptions options)
Creates a Mongo instance based on a (single) mongo node using a given ServerAddress and default options.
MongoClient(final List seeds, final List credentialsList)

Creates an instance based on a list of replica set members or mongos servers.

MongoClient(final List seeds, final MongoClientOptions options)

Construct an instance based on a list of replica set members or mongos servers.

MongoClient(final MongoClientURI uri, final MongoDriverInformation mongoDriverInformation)
Creates a Mongo described by a URI.
MongoClient(final String host)
Creates a Mongo instance based on a (single) mongodb node.
MongoClient(final ServerAddress addr)
Creates a Mongo instance based on a (single) mongodb node
MongoClient(final List seeds)

Creates an instance based on a list of replica set members or mongos servers.

MongoClient(final MongoClientURI uri)
Creates a Mongo described by a URI.
MongoClient()
Creates an instance based on a (single) mongodb node (localhost, default port).
MongoClient(final ServerAddress addr, final List credentialsList, final MongoClientOptions options)
Creates a Mongo instance based on a (single) mongo node using a given ServerAddress and default options.
MongoClient(final ServerAddress addr, final MongoCredential credential, final MongoClientOptions options)
Creates a Mongo instance based on a (single) mongo node using a given server address, credential, and options
MongoClient(final List seeds, final List credentialsList, final MongoClientOptions options)

Creates an instance based on a list of replica set members or mongos servers.

MongoClient(final List seeds, final MongoCredential credential, final MongoClientOptions options)

Creates an instance based on a list of replica set members or mongos servers.

Method

voidclose()
Closes all resources associated with this instance, in particular any open network connections.
voiddropDatabase(final String dbName)
Drops the database if it exists.
CommandResultfsync(final boolean async)
Forces the master server to fsync the RAM data to disk This is done automatically by the server at intervals, but can be forced for better reliability.
CommandResultfsyncAndLock()
Forces the master server to fsync the RAM data to disk, then lock all writes.
ServerAddressgetAddress()
Gets the address of the current master
ListgetAllAddress()
Gets a list of all server addresses used when this Mongo was created
StringgetConnectPoint()
Gets a String representation of current connection point, i.e.
MongoDatabasegetDatabase(final String databaseName)
ListgetDatabaseNames()
Gets a list of the names of all databases on the connected server.
DBgetDB(final String dbName)
Gets a database object.
CodecRegistrygetDefaultCodecRegistry()
Gets the default codec registry.
intgetMaxBsonObjectSize()
Gets the maximum size for a BSON object supported by the current master server.
MongoClientOptionsgetMongoClientOptions()
Gets the options that this client uses to connect to server.
MongoOptionsgetMongoOptions()

Returns the mongo options.

Changes to MongoOptions that are done after connection are not reflected.

intgetOptions()
Gets the default query options for reads operations executed on any DBCollection created indirectly from this instance, via a DB instance created from #getDB(String) .
ReadPreferencegetReadPreference()
Gets the default read preference
ReplicaSetStatusgetReplicaSetStatus()
Get the status of the replica set cluster.
ListgetServerAddressList()
Gets the list of server addresses currently seen by this client.
WriteConcerngetWriteConcern()
Gets the write concern
booleanisLocked()
Returns true if the database is locked (read-only), false otherwise.
MongoIterablelistDatabaseNames()
Get a list of the database names
voidsetOptions(final int options)
Set the default query options for reads operations executed on any DBCollection created indirectly from this instance, via a DB instance created from #getDB(String) .
voidsetReadPreference(final ReadPreference readPreference)
Sets the default read preference to use for reads operations executed on any DBCollection created indirectly from this instance, via a DB instance created from #getDB(String) .
voidsetWriteConcern(final WriteConcern writeConcern)
Sets the default write concern to use for write operations executed on any DBCollection created indirectly from this instance, via a DB instance created from #getDB(String) .
StringtoString()
DBObjectunlock()
Unlocks the database, allowing the write operations to go through.