@@ -149,3 +149,97 @@ POJO class:
149149If you are unable to find the answer to your question here, try our forums and
150150support channels listed in the :doc:`Issues and Help <issues-and-help>`
151151section.
152+
153+
154+ Legacy API
155+ ----------
156+
157+ .. _faq-legacy-connection:
158+
159+ How do I connect to my MongoDB instance with the legacy API?
160+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161+
162+ The following example shows how to connect to a MongoDB instance with the
163+ legacy API and the current API.
164+
165+ Imagine we are connecting to a collection that contains only this document:
166+
167+ .. code-block:: json
168+ :copyable: false
169+
170+ {"_id": 1, "val": 1}
171+
172+ .. tabs::
173+
174+ .. tab:: Legacy API
175+ :tabid: legacy
176+
177+ .. literalinclude:: /includes/fundamentals/code-snippets/LegacyAPI.java
178+ :language: java
179+ :dedent:
180+ :start-after: start legacy-api-example
181+ :end-before: end legacy-api-example
182+
183+ .. tab:: Current API
184+ :tabid: current
185+
186+ .. literalinclude:: /includes/fundamentals/code-snippets/CurrentAPI.java
187+ :language: java
188+ :dedent:
189+ :start-after: start current-api-example
190+ :end-before: end current-api-example
191+
192+ The output of the above code snippet should look like this:
193+
194+ .. code-block:: json
195+ :copyable: false
196+
197+ {"_id": 1, "val": 1}
198+
199+ For more information on the legacy classes and methods used in the above example,
200+ see the following API documentation pages:
201+
202+ - :java-docs:`Legacy API Javadoc Site <apidocs/mongodb-driver-legacy/index.html>`
203+ - :java-docs:`MongoClient <apidocs/mongodb-driver-legacy/com/mongodb/MongoClient.html>`
204+ - :java-docs:`DB <apidocs/mongodb-driver-legacy/com/mongodb/DB.html>`
205+ - :java-docs:`DBCollection <apidocs/mongodb-driver-legacy/com/mongodb/DBCollection.html>`
206+ - :java-docs:`DBObject <apidocs/mongodb-driver-core/com/mongodb/DBObject.html>`
207+ - :java-docs:`getDB() <apidocs/mongodb-driver-legacy/com/mongodb/MongoClient.html#getDB(java.lang.String)>`
208+ - :java-docs:`getCollection() <apidocs/mongodb-driver-legacy/com/mongodb/DB.html#getCollection(java.lang.String)>`
209+ - :java-docs:`find() <apidocs/mongodb-driver-legacy/com/mongodb/DBCollection.html#find()>`
210+ - :java-docs:`one() <apidocs/mongodb-driver-legacy/com/mongodb/DBCursor.html#one()>`
211+
212+
213+ How do I use the legacy ``MongoClientOptions`` and ``MongoClientURI`` Classes?
214+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215+
216+ Here is an example showing how to use the legacy ``MongoClientOptions`` and
217+ ``MongoClientURI`` classes to set your write concern:
218+
219+ .. tabs::
220+
221+ .. tab:: Legacy API
222+ :tabid: legacy
223+
224+ .. literalinclude:: /includes/fundamentals/code-snippets/LegacyAPI.java
225+ :language: java
226+ :dedent:
227+ :start-after: start legacy-api-mongoclientoptions-example
228+ :end-before: end legacy-api-mongoclientoptions-example
229+
230+ .. tab:: Current API
231+ :tabid: current
232+
233+ .. literalinclude:: /includes/fundamentals/code-snippets/CurrentAPI.java
234+ :language: java
235+ :dedent:
236+ :start-after: start current-api-mongoclientsettings-example
237+ :end-before: end current-api-mongoclientsettings-example
238+
239+ For more information on the legacy classes and methods used in the above example,
240+ see the following API documentation pages:
241+
242+ - :java-docs:`Legacy API Javadoc Site <apidocs/mongodb-driver-legacy/index.html>`
243+ - :java-docs:`MongoClient <apidocs/mongodb-driver-legacy/com/mongodb/MongoClient.html>`
244+ - :java-docs:`MongoClientOptions <apidocs/mongodb-driver-legacy/com/mongodb/MongoClientOptions.html>`
245+ - :java-docs:`MongoClientURI <apidocs/mongodb-driver-legacy/com/mongodb/MongoClientURI.html>`
0 commit comments