You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
object to the `MongoClients.create() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoClients.html#create(com.mongodb.MongoClientSettings)>`__
@@ -25,6 +39,88 @@ To create a ``MongoClientSettings`` object, use the
25
39
your desired settings. After chaining all the settings you want, use the
26
40
``build()`` method to create the ``MongoClientSettings`` object.
27
41
42
+
The following table describes all the methods you can chain to your
43
+
settings to modify the driver's behavior:
44
+
45
+
.. list-table::
46
+
:widths: 40 60
47
+
:header-rows: 1
48
+
49
+
* - Method
50
+
- Description
51
+
52
+
* - ``addCommandListener()``
53
+
- Adds a listener for :ref:`command events <command-events-java>`.
54
+
55
+
* - ``applicationName()``
56
+
- Sets the logical name of the application using the ``MongoClient``.
57
+
58
+
* - ``applyConnectionString()``
59
+
- Applies the settings from the given ``ConnectionString`` to the builder. If you omit this method, the driver attempts to connect to ``localhost``.
60
+
61
+
* - ``applyToClusterSettings()``
62
+
- Applies the ``ClusterSettings.Builder`` block and then sets the :ref:`cluster settings <mcs-cluster-settings>`.
63
+
64
+
* - ``applyToConnectionPoolSettings()``
65
+
- Applies the ``ConnectionPoolSettings.Builder`` block and then sets the :ref:`connection pool settings <mcs-connectionpool-settings>`.
66
+
67
+
* - ``applyToServerSettings()``
68
+
- Applies the ``ServerSettings.Builder`` block and then sets the :ref:`server settings <mcs-server-settings>`.
69
+
70
+
* - ``applyToSocketSettings()``
71
+
- Applies the ``SocketSettings.Builder`` block and then sets the :ref:`socket settings <mcs-socket-settings>`.
72
+
73
+
* - ``applyToSslSettings()``
74
+
- Applies the ``SslSettings.Builder`` block and then sets the :ref:`TLS/SSL settings <mcs-ssl-settings>`.
75
+
76
+
* - ``autoEncryptionSettings()``
77
+
- | Sets the :ref:`auto-encryption settings <auto-encryption-decryption-java>`.
78
+
|
79
+
| If you omit ``keyVaultClient`` or set
80
+
| ``bypassAutomaticEncryption`` to false in your
81
+
| ``AutoEncryptionSettings``, the driver creates a separate,
82
+
| internal ``MongoClient``.
83
+
|
84
+
| The internal ``MongoClient`` configuration differs from the
85
+
| parent ``MongoClient`` by setting the ``minPoolSize`` to 0 and
86
+
| omitting the ``AutoEncryptionSettings``.
87
+
88
+
* - ``codecRegistry()``
89
+
- Sets the :ref:`codec registry <codecs-codecregistry>`.
90
+
91
+
* - ``commandListenerList()``
92
+
- Sets the :ref:`command listeners <command-events-java>`.
93
+
94
+
* - ``compressorList()``
95
+
- Sets the :ref:`compressors <compression>` to use for compressing messages to the server.
96
+
97
+
* - ``credential()``
98
+
- Sets the :ref:`credential <authentication-mechanisms-java>`.
99
+
100
+
* - ``readConcern()``
101
+
- Sets the :manual:`read concern </reference/read-concern/>`.
102
+
103
+
* - ``readPreference()``
104
+
- Sets the :manual:`read preference </core/read-preference/>`.
105
+
106
+
* - ``retryReads()``
107
+
- Whether the driver should :manual:`retry reads </core/retryable-reads/>` if a network error occurs.
108
+
109
+
* - ``retryWrites()``
110
+
- Whether the driver should :manual:`retry writes </core/retryable-writes/>` if a network error occurs.
111
+
112
+
* - ``serverApi()``
113
+
- Sets the :ref:`server API <versioned-api-java>` to use when sending commands to the server.
114
+
115
+
* - ``streamFactoryFactory()``
116
+
- Sets the factory to use to create a ``StreamFactory``.
117
+
118
+
* - ``uuidRepresentation()``
119
+
- Sets the UUID representation to use when encoding instances of UUID and decoding BSON binary values with subtype of 3.
120
+
121
+
* - ``writeConcern()``
122
+
- Sets the :manual:`write concern </reference/write-concern/>`.
123
+
28
124
.. _connection-string-example:
29
125
30
126
Example
@@ -39,22 +135,6 @@ This example demonstrates specifying a ``ConnectionString``:
39
135
:emphasize-lines: 3
40
136
:dedent:
41
137
42
-
.. tip::
43
-
44
-
If you omit the ``applyConnectionString()`` method, the driver
45
-
attempts to connect to ``localhost``.
46
-
47
-
For a list of methods available in ``MongoClientSettings``,
48
-
see the `API Documentation <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html>`__.
49
-
50
-
The following sections describe commonly used settings:
51
-
52
-
- :ref:`Cluster Settings <mcs-cluster-settings>`
53
-
- :ref:`Socket Settings <mcs-socket-settings>`
54
-
- :ref:`Connection Pool Settings <mcs-connectionpool-settings>`
55
-
- :ref:`Server Settings <mcs-server-settings>`
56
-
- :ref:`TLS/SSL Settings <mcs-ssl-settings>`
57
-
58
138
.. tip::
59
139
60
140
Each setting has an ``applyConnectionString()`` method. They are
0 commit comments