7

what are the major differences between mongoclientoptions vs mongoclientsettings

Can anyone please give an example and elaborate where to use what with example?

Pandit
  • 748
  • 1
  • 7
  • 22

1 Answers1

3

The short answer from what I can tell is the MongoClientOptions is the old way, whereas MongoClientSettings is the new way.

The newest MongoDB Java driver (3.9 at time of writing this answer) supports the old client - i.e., com.mongodb.MongoClient() which takes as a parameter MongoClientOptions. See https://mongodb.github.io/mongo-java-driver/3.9/javadoc/com/mongodb/MongoClient.html.

The newer client has a different namespace - it is com.mongodb.client.MongoClient(). This client expects to be built using com.mongodb.client.MongoClients.create(), which takes a MongoClientSettings. See https://mongodb.github.io/mongo-java-driver/3.9/javadoc/com/mongodb/client/MongoClients.html

barrypicker
  • 9,740
  • 11
  • 65
  • 79