@@ -47,46 +47,45 @@ usage limits, such as max connections, apply to individual
4747
4848.. _connection-uri:
4949
50- Connection String
51- -----------------
50+ Connection URI
51+ --------------
5252
53- The **connection string** (also known as a **connection uri**) provides
54- instructions on how to connect to a MongoDB deployment. The driver
55- URL interprets the connection string to determine where and how
56- it should connect to MongoDB as well as how to behave while
57- connected. The following example shows each part of the connection URI:
53+ The **connection URI** provides a set of instructions that the driver uses to
54+ connect to a MongoDB deployment. It instructs the driver on how it should
55+ connect to MongoDB and how it should behave while connected. The following
56+ example explains each part of a sample connection URI:
5857
59- .. figure:: /includes/figures/connection_string_parts .png
58+ .. figure:: /includes/figures/connection_uri_parts .png
6059 :alt: Connection String parts figure
6160
62- In this example, for the protocol, we use ``mongodb+srv`` which specifies the
63- :manual:`DNS Seedlist Connection Format </reference/connection-string/#std-label-connections-dns-seedlist>`.
64- This indicates that the hostname following it corresponds to the DNS SRV record of your
65- MongoDB instance or deployment. If your instance or deployment does not have a
66- DNS SRV record, use ``mongodb`` to specify the :manual:`Standard Connection
67- Format </reference/connection-string/#standard-connection-string-format>` .
61+ In this example, we use the :manual:`Standard Connection String Format
62+ </reference/connection-string/#std-label-connections-standard-connection-string-format>`,
63+ ``mongodb`` for the protocol. You can also use the :manual:` DNS Seed
64+ List Connection Format </reference/connection-string/#dns-seed-list-connection-format>`,
65+ ``mongodb+srv``, if you want more flexibility of deployment and the
66+ ability to change the servers in rotation without reconfiguring clients .
6867
6968.. note::
7069
71- If your deployment is on MongoDB Atlas, follow the
70+ If your deployment is on MongoDB Atlas, see the
7271 :atlas:`Atlas driver connection guide </driver-connection?jmp=docs_driver_java>`
73- to retrieve your connection string.
72+ and select Java from the language dropdown to retrieve your connection string.
7473
75- The next part of the connection string contains your username and password
76- if you are using password-based authentication. Replace the value of ``user``
77- with your username and ``pass`` with your password. If you are using an
78- authentication mechanism that does not require a username and password, omit
79- this part of the connection URI.
74+ The next part of the connection URI contains your credentials if you are
75+ using a password-based authentication mechanism . Replace the value of ``user``
76+ with your username and ``pass`` with your password. If your
77+ authentication mechanism does not require credentials, omit this part of
78+ the connection URI.
8079
81- The next part of the connection string specifies the hostname or IP address and
82- port of your MongoDB instance. In the following example, we use ``sample-hostname``
83- as the hostname and ``27017`` as the port. Replace these values to point to
84- your MongoDB instance.
80+ The next part of the connection URI specifies the hostname or IP
81+ address, followed by the port of your MongoDB instance. In the example,
82+ we use ``sample.host`` as the hostname and ``27017`` as the port.
83+ Replace these values to refer to your MongoDB instance.
8584
86- The last part of the connection string contains connection and authentication
87- options as parameters. In the following example, we set two connection options:
88- ``retryWrites=true`` and `` w=majority``. For more information on connection
89- options, skip to the :ref:`connection options <connection -options> ` section.
85+ The last part of the connection URI contains connection options as parameters. In the
86+ example, we set two connection options: ``maxPoolSize=20`` and
87+ ``w=majority``. For more information on connection options, skip to the
88+ :ref:`connection-options` section of this guide .
9089
9190.. _connect-atlas-java-driver:
9291
@@ -95,6 +94,7 @@ connect to MongoDB.
9594
9695.. literalinclude:: /includes/fundamentals/code-snippets/srv.java
9796 :language: java
97+ :emphasize-lines: 17
9898
9999.. _java-other-ways-to-connect:
100100
@@ -159,7 +159,7 @@ Select the tab corresponding to the code snippet you would like to see:
159159
160160 .. code-block:: java
161161
162- ConnectionString connectionString = new ConnectionString("mongodb://host1:27017,host2:27017,host3:27017");
162+ ConnectionString connectionString = new ConnectionString("mongodb://host1:27017,host2:27017,host3:27017/ ");
163163 MongoClient mongoClient = MongoClients.create(connectionString);
164164
165165 .. tab:: MongoClientSettings
@@ -230,14 +230,14 @@ using a method in the ``MongoClientSettings.Builder`` class.
230230 :tabid: connectionstring
231231
232232 To enable compression with a `ConnectionString
233- <{+api+}/apidocs/mongodb-driver-sync /com/mongodb/ConnectionString.html>`__, use the parameter ``compressors``
233+ <{+api+}/apidocs/mongodb-driver-core /com/mongodb/ConnectionString.html>`__, use the parameter ``compressors``
234234 in the connection string passed to
235235 ``MongoClients.create()``. You can specify one or more compression
236236 algorithms, separating multiple algorithms with commas:
237237
238238 .. code-block:: java
239239
240- ConnectionString connectionString = new ConnectionString("mongodb+srv://<user>:<password>@<cluster-url>?compressors=snappy,zlib,zstd");
240+ ConnectionString connectionString = new ConnectionString("mongodb+srv://<user>:<password>@<cluster-url>/ ?compressors=snappy,zlib,zstd");
241241 MongoClient mongoClient = MongoClients.create(connectionString);
242242
243243 Specify compression algorithms using the following strings:
@@ -350,12 +350,6 @@ parameters of the connection URI to specify the behavior of the client.
350350 constraints in other ways, use a
351351 :ref:`custom SSLContext <tls-custom-sslContext>`.
352352
353- * - **sslInvalidHostNameAllowed**
354- - boolean
355- - Specifies that the driver should allow invalid hostnames in the
356- certificate for TLS/SSL connections. Superseded by
357- **tlsAllowInvalidHostnames**.
358-
359353 * - **tlsAllowInvalidHostnames**
360354 - boolean
361355 - Specifies that the driver should allow invalid hostnames in the
@@ -383,7 +377,7 @@ parameters of the connection URI to specify the behavior of the client.
383377 - Specifies the maximum amount of time, in milliseconds, the Java
384378 driver will continue to use a pooled connection before closing the
385379 connection.
386-
380+
387381 * - **journal**
388382 - boolean
389383 - Specifies that the driver must wait for the connected MongoDB
@@ -477,14 +471,14 @@ parameters of the connection URI to specify the behavior of the client.
477471 - boolean
478472 - Specifies that the driver must retry supported read operations
479473 if they fail due to a network error. Defaults to ``true``.
480-
474+
481475 * - **uuidRepresentation**
482476 - string
483477 - Specifies the UUID representation to use for read and write
484478 operations. For more information, see the the driver documentation
485479 for the
486480 `MongoClientSettings.getUuidRepresentation() method <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.html#getUuidRepresentation()>`__.
487-
481+
488482 * - **directConnection**
489483 - boolean
490484 - Specifies that the driver must connect to the host directly.
0 commit comments