-
Notifications
You must be signed in to change notification settings - Fork 43
DOCSP-47777: Rework get started #619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
norareidy
merged 12 commits into
mongodb:master
from
norareidy:DOCSP-47777-get-started-reorg
Mar 3, 2025
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
385cce1
DOCSP-47777: Rework get started
norareidy d1f9ec6
edits
norareidy 048d350
snooty
norareidy 06a30ce
fixes
norareidy da3d7b5
build errors
norareidy 9f4bf8d
RM feedback
norareidy 0e62609
fix
norareidy 769c4b6
capitalize
norareidy ca98cc5
punctuation
norareidy 67eb77a
toc
norareidy 3886538
add back integrations
norareidy 3418ea2
tech review
norareidy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.. _java-get-started: | ||
|
||
================================ | ||
Get Started with the Java Driver | ||
================================ | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: tutorial | ||
|
||
.. meta:: | ||
:description: Learn how to create an app to connect to MongoDB deployment by using the {+driver-short+}. | ||
:keywords: quick start, tutorial, basics | ||
|
||
.. toctree:: | ||
|
||
Download & Install </get-started/download-and-install/> | ||
Create a Deployment </get-started/create-deployment/> | ||
Create a Connection String </get-started/connection-string/> | ||
Connect to MongoDB </get-started/connect-to-mongodb/> | ||
Next Steps </get-started/next-steps/> | ||
Databases & Collections </get-started/databases-collections/> | ||
Integrations </get-started/integrations/> | ||
|
||
Overview | ||
-------- | ||
|
||
The {+driver-short+} is a synchronous API that you can use to interact with MongoDB | ||
from your Java application. This guide shows you how to create an application that | ||
uses the {+driver-short+} to connect to a MongoDB cluster hosted on MongoDB Atlas | ||
and query data in your cluster. | ||
|
||
.. tip:: | ||
|
||
:atlas:`MongoDB Atlas </getting-started/>` is a fully managed cloud database service | ||
that hosts your MongoDB deployments. You can create your own free (no credit card required) | ||
MongoDB Atlas deployment by following the steps in this guide. | ||
|
||
Follow this tutorial to connect a sample Java application to a MongoDB Atlas | ||
deployment. The tutorial includes the following sections: | ||
|
||
- :ref:`java-get-started-download-and-install`: Learn how to install | ||
the {+driver-short+}. | ||
- :ref:`java-get-started-create-deployment`: Learn how to create | ||
a free MongoDB deployment on Atlas. | ||
- :ref:`java-get-started-connection-string`: Learn how to retrieve | ||
your Atlas deployment's connection string. | ||
- :ref:`java-connect-to-mongodb`: Learn how to create an application | ||
that connects to MongoDB and queries data stored in your deployment. | ||
|
||
If you prefer to connect to MongoDB using a different driver or | ||
programming language, see our :driver:`list of official drivers <>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.. _java-connect-to-mongodb: | ||
|
||
================== | ||
Connect to MongoDB | ||
================== | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: tutorial | ||
|
||
.. meta:: | ||
:keywords: test connection, runnable, code example | ||
|
||
After retrieving the connection string for your MongoDB Atlas deployment, | ||
you can connect to the deployment from your Java application and query | ||
the Atlas sample datasets. | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Create your Java application file | ||
|
||
In your project's base package directory, create a file called | ||
``QuickStart.java``. Copy and paste the following code into this file, | ||
which queries the ``movies`` collection in the ``sample_mflix`` database: | ||
|
||
.. literalinclude:: /includes/get-started/code-snippets/QuickStart.java | ||
:start-after: begin QuickStart | ||
:end-before: end QuickStart | ||
:language: java | ||
:dedent: | ||
|
||
.. step:: Assign the connection string | ||
|
||
Replace the ``<connection string uri>`` placeholder with the connection string | ||
that you copied from the :ref:`java-get-started-connection-string` step of this | ||
guide. | ||
|
||
.. step:: Run your Java application | ||
|
||
Run your application in your IDE or your shell. Your output | ||
contains details about the retrieved movie document: | ||
|
||
.. include:: /includes/get-started/query-output.rst | ||
|
||
.. include:: /includes/get-started/jdk-tls-issue.rst | ||
|
||
After you complete these steps, you have a Java application that | ||
connects to your MongoDB deployment, runs a query on the sample | ||
data, and returns a matching document. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
.. _java-get-started-connection-string: | ||
|
||
========================== | ||
Create a Connection String | ||
========================== | ||
|
||
You can connect to your MongoDB deployment by providing a | ||
**connection URI**, also called a *connection string*, which | ||
instructs the driver on how to connect to a MongoDB deployment | ||
and how to behave while connected. | ||
|
||
The connection string includes the hostname or IP address and | ||
port of your deployment, the authentication mechanism, user credentials | ||
when applicable, and connection options. | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Find your MongoDB Atlas connection string | ||
|
||
To retrieve your connection string for the deployment that | ||
you created in the :ref:`previous step <java-get-started-create-deployment>`, | ||
log into your Atlas account and navigate to the | ||
:guilabel:`Clusters` section. Click the :guilabel:`Connect` button | ||
for your new deployment, as shown in the following screenshot: | ||
|
||
.. figure:: /includes/figures/atlas_connection_connect_cluster.png | ||
:alt: The connect button in the clusters section of the Atlas UI | ||
|
||
Then, proceed to the :guilabel:`Connect your application` section. Select | ||
"Java" from the :guilabel:`Driver` selection menu and the version | ||
that best matches the version you installed from the :guilabel:`Version` | ||
selection menu. | ||
|
||
.. step:: Copy your connection string | ||
|
||
Click the button on the right of the connection string to copy it to | ||
your clipboard, as shown in the following screenshot: | ||
|
||
.. figure:: /includes/figures/atlas_connection_copy_uri_java.png | ||
:alt: The connection string copy button in the Atlas UI | ||
|
||
.. step:: Edit your connection string placeholders | ||
|
||
Paste your connection string into a file in your preferred text editor | ||
and save this file to a safe location for later use. In your connection | ||
string, replace the ``<db_username>`` and ``<db_password>`` placeholders with | ||
your database user's username and password. | ||
|
||
After completing these steps, you have a connection string that | ||
contains your database username and password. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. _java-get-started-create-deployment: | ||
|
||
=========================== | ||
Create a MongoDB Deployment | ||
=========================== | ||
|
||
You can create a free tier MongoDB deployment on MongoDB Atlas | ||
to store and manage your data. MongoDB Atlas hosts and manages | ||
your MongoDB database in the cloud. | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Create a free MongoDB deployment on Atlas | ||
|
||
Complete the :atlas:`Get Started with Atlas </getting-started?tck=docs_driver_java>` | ||
guide to set up a new Atlas account and a free tier MongoDB deployment. | ||
Ensure that you **load sample data** and **add your IP address** to the IP access | ||
list. | ||
|
||
.. step:: Save your credentials | ||
|
||
After you create your database user, save that user's | ||
username and password to a safe location for use in an upcoming step. | ||
|
||
After you complete these steps, you have a new free tier MongoDB | ||
deployment on Atlas, database user credentials, and sample data loaded | ||
in your database. |
2 changes: 2 additions & 0 deletions
2
...getting-started/databases-collections.txt → source/get-started/databases-collections.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _java-db-coll: | ||
|
||
========================= | ||
Databases and Collections | ||
========================= | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.. _java-get-started-download-and-install: | ||
|
||
==================== | ||
Download and Install | ||
==================== | ||
|
||
Complete the following steps to install the {+driver-short+} and | ||
its dependencies in your development environment. | ||
|
||
.. procedure:: | ||
:style: connected | ||
|
||
.. step:: Install the driver dependencies | ||
|
||
Before you begin this tutorial, ensure that you install | ||
the following dependencies: | ||
|
||
- `JDK <https://www.oracle.com/java/technologies/javase-downloads.html>`__ | ||
version 8 or later | ||
- Integrated development environment (IDE), such as `IntelliJ IDEA <https://www.jetbrains.com/idea/download/>`__ | ||
or `Eclipse <https://www.eclipse.org/downloads/packages/>`__ | ||
|
||
.. note:: | ||
|
||
This tutorial shows how to install the {+driver-short+} by using | ||
Maven or Gradle in an IDE. If you do not use an IDE, visit `Building Maven | ||
<https://maven.apache.org/guides/development/guide-building-maven.html>`__ | ||
or `Creating New Gradle Builds <https://guides.gradle.org/creating-new-gradle-builds/>`__ | ||
to learn how to set up your project. | ||
|
||
.. step:: Install the {+driver-short+} | ||
|
||
In your IDE, create a new `Maven <https://maven.apache.org/>`__ or `Gradle <https://gradle.org/>`__ | ||
project. If you use Maven, add the following code to your ``pom.xml`` dependencies list: | ||
|
||
.. code-block:: xml | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.mongodb</groupId> | ||
<artifactId>mongodb-driver-sync</artifactId> | ||
<version>{+full-version+}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
If you use Gradle, add the following code to your ``build.gradle`` dependencies list: | ||
|
||
.. code-block:: groovy | ||
|
||
dependencies { | ||
implementation 'org.mongodb:mongodb-driver-sync:{+full-version+}' | ||
} | ||
|
||
After you configure your dependencies, ensure they are available to your | ||
project by running your dependency manager and refreshing | ||
the project in your IDE. | ||
|
||
After you complete these steps, you have a new project | ||
and the driver dependencies installed. | ||
|
||
.. include:: /includes/get-started/quickstart-troubleshoot.rst |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.. _java-get-started-next-steps: | ||
|
||
========== | ||
Next Steps | ||
========== | ||
|
||
Congratulations on completing the tutorial! | ||
|
||
In this tutorial, you created a {+driver-short+} application that | ||
connects to a MongoDB deployment hosted on MongoDB Atlas | ||
and retrieves a document that matches a query. | ||
|
||
You can continue to develop your sample application by | ||
visiting the following guides: | ||
|
||
- :ref:`java-db-coll`: Learn more about interacting with | ||
MongoDB databases and collections. | ||
- :ref:`java-integrations`: Learn about the third-party | ||
integrations that you can use with the {+driver-short+}. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional]
Let's make those bold instructions into links to https://www.mongodb.com/docs/atlas/sample-data/ and https://www.mongodb.com/docs/atlas/security/add-ip-address-to-list/ respectively?