Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (72 sloc) 3.17 KB
.. _java-language-center:
.. include:: /includes/unicode-checkmark.rst
===================
Java MongoDB Driver
===================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: twocols
Introduction
------------
The official MongoDB Java Driver providing both synchronous and asynchronous interaction with MongoDB.
- :java-docs-latest:`Tutorials <driver/tutorials/>`
- :java-docs-latest:`Usage Guide <driver/>`
- :java-docs-latest:`API Documentation <javadoc/overview-summary.html>`
- :java-docs-latest:`Changelog <whats-new/>`
- `Source Code <https://github.com/mongodb/mongo-java-driver/>`__
Take the free online course taught by MongoDB
---------------------------------------------
.. list-table::
* - .. cssclass:: bordered-figure
.. figure:: /figures/M220J_hero.jpg
- `M220J: MongoDB for Java Developers <https://university.mongodb.com/courses/M220J/about>`__
Learn the essentials of Java application development with MongoDB.
Installation
------------
The recommended way to get started using one of the drivers in your project is with a dependency
management system. See
:java-docs-latest:`Installation Guide <driver/getting-started/installation/>`
Connect to MongoDB Atlas
------------------------
To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use the `Atlas connection string <https://docs.atlas.mongodb.com/driver-connection>`__ for your cluster:
.. code-block:: java
import com.mongodb.ConnectionString;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoDatabase;
import com.mongodb.MongoClientSettings;
// ...
ConnectionString connString = new ConnectionString(
"mongodb+srv://<username>:<password>@<cluster-address>/test?w=majority"
);
MongoClientSettings settings = MongoClientSettings.builder()
.applyConnectionString(connString)
.retryWrites(true)
.build();
MongoClient mongoClient = MongoClients.create(settings);
MongoDatabase database = mongoClient.getDatabase("test");
See :java-docs-latest:`Connect to MongoDB <driver/tutorials/connect-to-mongodb/>`
for more ways to connect.
Compatibility
-------------
MongoDB Compatibility
~~~~~~~~~~~~~~~~~~~~~
.. include:: /includes/mongodb-compatibility-table-java.rst
.. include:: /includes/older-server-versions-unsupported.rst
.. [*] The 2.14 driver does not support all MongoDB 3.2 features (e.g.,
read concern); however, if you are currently on a version 2.x driver
and would like to run against MongoDB 3.2 but cannot upgrade to driver
version 3.2, use the 2.14 driver.
Language Compatibility
~~~~~~~~~~~~~~~~~~~~~~
.. include:: /includes/extracts/java-driver-compatibility-matrix-language.rst
.. include:: /includes/language-compatibility-table-java.rst
How to get help
---------------
- Join our `Google Group <https://groups.google.com/forum/#!forum/mongodb-user>`__.
- Ask on `Stack Overflow <https://stackoverflow.com/questions/tagged/mongodb+java>`__.
- Visit our `Support Channels <https://docs.mongodb.com/manual/support/>`__.
- See :java-docs-latest:`Issues & Help <issues-help/>`.
You can’t perform that action at this time.