ConnectionString (driver-core 5.4.0 API) (original) (raw)


public class ConnectionString extends Object

Represents a Connection String. The Connection String describes the hosts to be used and options.

The format of the Connection String is:

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

An alternative format, using the mongodb+srv protocol, is:

mongodb+srv://[username:password@]host[/[database][?options]]

The following options are supported (case insensitive):

Server Selection Configuration:

Server Monitoring Configuration:

Replica set configuration:

Connection Configuration:

Proxy Configuration:

Connection pool configuration:

Write concern configuration:

Read preference configuration:

Authentication configuration:

Server Handshake configuration:

Compressor configuration:

SRV configuration:

General configuration:

Since:

3.0.0

MongoDB documentation

Connection String Format

Constructors
Creates a ConnectionString from the given string.
Creates a ConnectionString from the given string with the given DnsClient.

boolean
Gets the logical name of the application.
Gets the list of compressors.
Get the unparsed connection string.
Gets the socket connect timeout specified in the connection string.
Gets the credential or null if no credentials were specified in the connection string.
[getHosts](#getHosts%28%29)()
Gets the maximum number of connections a pool may be establishing concurrently specified in the connection string.
Gets the maximum connection idle time specified in the connection string.
Gets the maximum connection lifetime specified in the connection string.
Gets the maximum connection pool size specified in the connection string.
Gets the minimum connection pool size specified in the connection string.
char[]
Gets the SOCKS5 proxy host specified in the connection string.
Gets the SOCKS5 proxy password specified in the connection string.
Gets the SOCKS5 proxy port specified in the connection string.
Gets the SOCKS5 proxy username specified in the connection string.
Gets the read concern specified in the connection string.
Gets the read preference specified in the connection string.
Gets the required replica set name specified in the connection string.
Gets whether reads should be retried if they fail due to a network error
Gets whether writes should be retried if they fail due to a network error
The server monitoring mode, which defines the monitoring protocol to use.
Gets the socket timeout specified in the connection string.
Gets the maximum number of hosts to connect to when using SRV protocol.
Gets the SRV service name.
Gets the SSL enabled value specified in the connection string.
Gets the SSL invalidHostnameAllowed value specified in the connection string.
The time limit for the full execution of an operation in milliseconds.
Gets the UUID representation.
Gets the write concern specified in the connection string.
int
[hashCode](#hashCode%28%29)()
Indicates if the connection should be a direct connection
Indicates if the connection is through a load balancer.
boolean
Returns true if the connection string requires SRV protocol to resolve the host lists from the configured host.
[toString](#toString%28%29)()