@@ -3,7 +3,7 @@ Connection Guide
33================
44
55.. default-domain:: mongodb
6-
6+
77.. toctree::
88
99 /fundamentals/connection/tls
@@ -60,7 +60,7 @@ connected. The following example shows each part of the connection URI:
6060 :alt: Connection String parts figure
6161
6262In 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>`.
63+ :manual:`DNS Seedlist Connection Format </reference/connection-string/#std-label-connections-dns-seedlist>`.
6464This indicates that the hostname following it corresponds to the DNS SRV record of your
6565MongoDB instance or deployment. If your instance or deployment does not have a
6666DNS SRV record, use ``mongodb`` to specify the :manual:`Standard Connection
@@ -88,21 +88,36 @@ options as parameters. In the following example, we set two connection options:
8888``retryWrites=true`` and ``w=majority``. For more information on connection
8989options, skip to the :ref:`connection options <connection-options>` section.
9090
91+ .. _connect-atlas-java-driver:
92+
9193The following code shows how you can use the sample connection URI in a client to
9294connect to MongoDB.
9395
9496.. literalinclude:: /includes/fundamentals/code-snippets/srv.java
9597 :language: java
9698
97- .. _connect-replica-set :
99+ .. _java-other-ways-to-connect :
98100
99- Connect to ``localhost``
100- ~~~~~~~~~~~~~~~~~~~~~~~~
101+ Other Ways to Connect to MongoDB
102+ --------------------------------
103+
104+ If you are connecting to a single MongoDB server instance or replica set
105+ that is not hosted on Atlas, see the following sections to find out how to
106+ connect.
107+
108+ Connect to a MongoDB Server on Your Local Machine
109+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101110
102- .. include:: /includes/localhost-connection.rst
111+ .. include:: /includes/fundamentals/localhost-connection.rst
112+
113+ To test whether you can connect to your server, replace the connection
114+ string in the :ref:`Connect to MongoDB Atlas <connect-atlas-java-driver>` code
115+ example and run it.
116+
117+ .. _connect-replica-set:
103118
104119Connect to a Replica Set
105- ------------------------
120+ ~~~~~~~~~~~~~~~~~~~~~~~~
106121
107122A MongoDB replica set deployment is a group of connected instances that
108123store the same set of data. This configuration of instances provides data
@@ -151,7 +166,7 @@ Select the tab corresponding to the code snippet you would like to see:
151166 :tabid: mongoclientsettings
152167
153168 .. code-block:: java
154-
169+
155170 ServerAddress seed1 = new ServerAddress("host1", 27017);
156171 ServerAddress seed2 = new ServerAddress("host2", 27017);
157172 ServerAddress seed3 = new ServerAddress("host3", 27017);
@@ -236,11 +251,11 @@ using a method in the ``MongoClientSettings.Builder`` class.
236251 .. tab:: MongoClientSettings
237252 :tabid: mongoclientsettings
238253
239- To enable compression with
240- :java-docs:`MongoClientSettings <apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.html>`,
254+ To enable compression with
255+ :java-docs:`MongoClientSettings <apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.html>`,
241256 pass the
242257 :java-docs:`compressorList() <apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html#compressorList(java.util.List)>`
243- builder method a list of
258+ builder method a list of
244259 :java-docs:`MongoCompressor <apidocs/mongodb-driver-core/com/mongodb/MongoCompressor.html>`
245260 instances. You can specify one or more compression algorithms in the list:
246261
@@ -389,7 +404,7 @@ parameters of the connection URI to specify the behavior of the client.
389404 * - **readPreference**
390405 - string
391406 - Specifies the read preference. For more information on values, see
392- the server documentation for the
407+ the server documentation for the
393408 :manual:`readPreference option </reference/connection-string/#urioption.readPreference>`.
394409
395410 * - **readPreferenceTags**
@@ -467,13 +482,13 @@ parameters of the connection URI to specify the behavior of the client.
467482 - string
468483 - Specifies the UUID representation to use for read and write
469484 operations. For more information, see the the driver documentation
470- for the
485+ for the
471486 :java-docs:`MongoClientSettings.getUuidRepresentation() method <apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.html#getUuidRepresentation()>`.
472487
473488 * - **directConnection**
474489 - boolean
475490 - Specifies that the driver must connect to the host directly.
476491
477- For a complete list of options, see the
492+ For a complete list of options, see the
478493:java-docs:`ConnectionString <apidocs/mongodb-driver-core/com/mongodb/ConnectionString.html>`
479494API reference page.
0 commit comments