com.mongodb
Class MongoClientURI

java.lang.Object
  extended by com.mongodb.MongoClientURI

public class MongoClientURI
extends Object

Represents a URI which can be used to create a MongoClient instance. The URI describes the hosts to be used and options.

The format of the URI is:

   mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
 

The Java driver supports the following options (case insensitive):

Replica set configuration:

Connection Configuration:

Connection pool configuration:

Write concern configuration:

Read preference configuration:

Note: This class is a replacement for MongoURI, to be used with MongoClient. The main difference in behavior is that the default write concern is WriteConcern.ACKNOWLEDGED.

Since:
2.10.0
See Also:
for the default values for all options

Constructor Summary
MongoClientURI(String uri)
          Creates a MongoURI from the given string.
 
Method Summary
 String getCollection()
          Gets the collection name
 String getDatabase()
          Gets the database name
 List<String> getHosts()
          Gets the list of hosts
 MongoClientOptions getOptions()
          Gets the options
 char[] getPassword()
          Gets the password
 String getURI()
          Get the unparsed URI.
 String getUsername()
          Gets the username
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MongoClientURI

public MongoClientURI(String uri)
Creates a MongoURI from the given string.

Parameters:
uri - the URI
MongoDB Doc Links
Method Detail

getUsername

public String getUsername()
Gets the username

Returns:
the username

getPassword

public char[] getPassword()
Gets the password

Returns:
the password

getHosts

public List<String> getHosts()
Gets the list of hosts

Returns:
the host list

getDatabase

public String getDatabase()
Gets the database name

Returns:
the database name

getCollection

public String getCollection()
Gets the collection name

Returns:
the collection name

getURI

public String getURI()
Get the unparsed URI.

Returns:
the URI

getOptions

public MongoClientOptions getOptions()
Gets the options

Returns:
the MongoClientOptions based on this URI.

toString

public String toString()
Overrides:
toString in class Object