mongoclientoptions example

Example 1: mongoclientoptions example

MongoClient mongoClient = MongoClients.create("mongodb://host1:27017,host2:27017,host3:27017/?replicaSet=myReplicaSet");

Example 2: mongoclientoptions example

MongoClient mongoClient = MongoClients.create(
            MongoClientSettings.builder()
                    .applyToClusterSettings(builder ->
                            builder.hosts(Arrays.asList(
                                    new ServerAddress("host1", 27017),
                                    new ServerAddress("host2", 27017),
                                    new ServerAddress("host3", 27017))))
                    .build());

Example 3: mongoclientoptions example

MongoClient mongoClient = MongoClients.create("mongodb://host1:27017,host2:27017,host3:27017");