Microsoft Azure Cosmos DB for MongoDB
- Last Updated: May 25, 2022
- 1 minute read
- DataDirect Connectors
- JDBC
- MongoDB 6.1
- Documentation
This string includes the properties used to connect to a Microsoft Azure Cosmos DB for MongoDB. Connection strings for Azure Cosmos DB for MongoDB are similar to standard MongoDB connections, but require TLS encryption and authentication to be enabled.
jdbc:datadirect:mongodb://host:port;DatabaseName=database;EncryptionMethod=SSL;
ValidateServerCertificate=false;User=username;Password=password;[property=value[;...]];
where:
- host
-
specifies the name or the IP address of the Azure Cosmos DB for MongoDB server to which you want to connect. For example, myCosmosdbServer.
- port
-
specifies the port number of the server listener. This value is typically
10255for Azure Cosmos DB for MongoDB connections.
- 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.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
- (optional) specifies the your Azure Cosmos DB account name. For example, jsmith.
- password
- (optional) specifies the password used to connect to your Azure Cosmos DB account.
- 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 basic properties used for connecting to a Azure Cosmos DB database.
Connection conn = DriverManager.getConnection
("jdbc:datadirect:mongodb://myCosmosdbServer:10255;DatabaseName=mydb;
EncryptionMethod=SSL;ValidateServerCertificate=false;User=jsmith;Password=secret;");