Replica set failover
- Last Updated: October 6, 2021
- 1 minute read
- DataDirect Connectors
- JDBC
- MongoDB 6.1
- Documentation
This string includes the properties used to enable replica set failover for write operations with no authentication.
jdbc:datadirect:mongodb://host:port;AuthenticationMethod=None;DatabaseName=database;
ReplicaSetName=replica_set;[property=value[;...]];
where:
- host
specifies the name or the IP address of the MongoDB server to which you want to connect.
For example, myserver.
- port
-
specifies the port number of the server listener. The default is
27017.
- 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.
- replica_set
- specifies the name of the replica set against which you want to execute write operations.
- property=value
- specifies connection property settings. Multiple properties are separated by a semi-colon.
The following example connection string includes the properties used to enable replica set failover for write operations with no authentication:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:mongodb://MongodbServer:27017;AuthenticationMethod=None;
DatabaseName=Mongodb1;ReplicaSetName=MyReplicaSet;");