Docs Menu
Docs Home
MongoDB Atlas
/ / /

Connect with JDBC Driver

On this page

  • Supported Authentication Mechanisms
  • Prerequisites
  • Procedure

This page describes how to install and configure the MongoDB JDBC Driver for connecting to a federated database instance.

You can authenticate with SCRAM-SHA-1, SCRAM-SHA-256, MONGODB-X509, and MongoDB Passwordless Authentication with AWS.

  • A federated database instance mapped to one or more data stores.


    If some or all of your data comes from an Atlas cluster, you must use MongoDB version 5.0 or greater for that cluster to take advantage of Atlas SQL.

  • An application or BI tool that you want to connect to your federated database instance with the JDBC driver.

  • The MongoDB JDBC Driver.

You can use the JDBC driver to connect to SQL-based Java applications that accept a JDBC API, such as a Maven project.

Download the latest MongoDB JDBC Driver version from the MongoDB download center if you haven't already.


To connect with your Maven application, copy the dependency snippet from the Maven Central Repository. Edit the version number in the dependency snippet to match your JDBC driver version. For example:


In the pom.xml file for your project, paste the snippet into the dependencies list as follows:


To connect to your federated database instance, create a connection string and open a connection from your application. The connection string for the JDBC driver follows the format of the standard MongoDB connection string, except with the jdbc: prefix:


The following example demonstrates how to open a connection. In addition to the connection string, you must also specify the database to use through a Properties object parameter. To learn more, see Connection Strings and Connection Properties.

java.util.Properties p = new java.util.Properties();
p.setProperty("database", "<databaseName>");
Connection conn = DriverManager.getConnection("<connectionString>", p);


The driver can only connect to Atlas and not to a mongod instance. Any special characters in the connection string for the JDBC driver must be URL encoded.

← MongoDB Shell