I am trying to connect MongoDB Atlas with Java. This is my code
MongoClientSettings.Builder mongoClientSettingsBuilder = MongoClientSettings.builder()
.credential(mongoCredential)
.applyToClusterSettings(builder -> builder.hosts(new ServerAddress("dev-20937-liwy3.gcp.mongodb.net", 27017)));
MongoClientSettings settings = mongoClientSettingsBuilder.build();
MongoClient mongoClient = MongoClients.create(settings);
By doing so I am getting the following error
INFO: Cluster description not yet available. Waiting for 30000 ms before timing out
Mar 26, 2020 11:33:41 AM com.mongodb.diagnostics.logging.JULLogger log
Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=dev-20937-liwy3.gcp.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: dev-20937-liwy3.gcp.mongodb.net}, caused by {java.net.UnknownHostException: dev-20937-liwy3.gcp.mongodb.net}}]
I do not know the cause of the error. By my guess I have given my host name wrong.
Can someone help me out with this