Check MongoDB server is running and credentials are valid in Java
I am programming an UI where a user should be able to put in the URL and port to check whether a mongoDB server is running. Furthermore he should be able to provide credentials when necessary. If the server is not running or the credentials are wrong, I want to provide a message for each case. Similar questions have been answered here: Check MongoDB authentication with Java 3.0 driver how to check from a driver, if mongoDB server is running Unfortunately they use older versions of the Java driver for mongo. I'm using the 3.2+ version of the MongoDB java driver, where i.e. getDB() is deprecated