public class

MongoURI

extends Object
java.lang.Object
   ↳ com.mongodb.MongoURI

Class Overview

Represents a URI which can be used to create a Mongo instance. The URI describes the hosts to be used and options. The Java driver supports the following options (case insensitive):

  • maxpoolsize
  • waitqueuemultiple
  • waitqueuetimeoutms
  • connecttimeoutms
  • sockettimeoutms
  • autoconnectretry
  • slaveok
  • safe
  • w
  • wtimeout
  • fsync

Summary

Constants
String MONGODB_PREFIX
Public Constructors
MongoURI(String uri)
Creates a MongoURI described by a String.
Public Methods
Mongo connect()
creates a Mongo instance based on the URI@return
DBCollection connectCollection(Mongo m)
returns the URI's Collection from a given Mongo instance
DBCollection connectCollection(DB db)
returns the URI's Collection from a given DB object
DB connectDB()
returns the DB object from a newly created Mongo instance based on this URI@return
DB connectDB(Mongo m)
returns the URI's DB object from a given Mongo instance
String getCollection()
Gets the collection name
String getDatabase()
Gets the database name
List<String> getHosts()
Gets the list of hosts
MongoOptions getOptions()
Gets the options
char[] getPassword()
Gets the password
String getUsername()
Gets the username
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String MONGODB_PREFIX

Constant Value: "mongodb://"

Public Constructors

public MongoURI (String uri)

Creates a MongoURI described by a String. examples mongodb://127.0.0.1 mongodb://fred:foobar@127.0.0.1/

Parameters
uri the URI

Public Methods

public Mongo connect ()

creates a Mongo instance based on the URI@return

Throws
MongoException
UnknownHostException
MongoException

public DBCollection connectCollection (Mongo m)

returns the URI's Collection from a given Mongo instance

public DBCollection connectCollection (DB db)

returns the URI's Collection from a given DB object

public DB connectDB ()

returns the DB object from a newly created Mongo instance based on this URI@return

Throws
MongoException
UnknownHostException
MongoException

public DB connectDB (Mongo m)

returns the URI's DB object from a given Mongo instance

public String getCollection ()

Gets the collection name

public String getDatabase ()

Gets the database name

public List<String> getHosts ()

Gets the list of hosts

public MongoOptions getOptions ()

Gets the options

public char[] getPassword ()

Gets the password

public String getUsername ()

Gets the username

public String toString ()