This string includes the properties used to connect to a MongoDB Atlas cluster.

jdbc:datadirect:mongodb://host:27017;AuthenticationDatabase=auth_db;
  DatabaseName=database;EncryptionMethod=SSL;User=username;Password=password;
  [property=value[;...]];

where:

host

specifies the domain name of the MongoDB Atlas cluster to which you want to connect. At connection, the driver performs a DNS lookup to identify the member nodes of the domain, then connects to an available node.

port

specifies the port number of the server listener. The default is 27017.

auth_db

(recommended) specifies the database in which your user ID was created. This value allows you to explicitly select a set of credentials and permissions when the same user ID was created in multiple databases on the server.

Note: We recommend specifying a value for this option when using user ID and password authentication (AuthenticationMethod=userIdPassword) to ensure that the correct permissions are used for your connection.
database
(optional) specifies the name of the database to which you want to connect. This value is used as the default qualifier for unqualified table names in SQL queries. Required for User/ID password authentication.
Important: This value is case-insensitive if you have access privileges to query the list of databases on the server. If you do not have access, this value is case-sensitive.
user
specifies the user name that is used to connect to the MongoDB database. For example, jsmith.
password
specifies the password used to connect to your MongoDB database.
property=value
specifies connection property settings. Multiple properties are separated by a semi-colon.
Note: The User and Password properties are not required to be stored in the connection string. They can also be passed separately by the application.

The following example connection string includes the properties required for connecting to a MongoDB Atlas cluster.

Connection conn = DriverManager.getConnection
  ("jdbc:datadirect:mongodb://myaltas.mongodb.net:27017;AuthenticationDatabase=mydb2;
         DatabaseName=mydb;EncryptionMethod=SSL;User=jsmith;Password=secret;");