I’ve downloaded JDBC driver for MongoDB but when using it with the correct username password, it throws the error:
Exception in thread "main" java.sql.SQLException: Failed to authenticate database 'testdb', Error code: :18] - "Authentication failed."..
Class.forName("cdata.jdbc.mongodb.MongoDBDriver");
Properties prop = new Properties();
prop.setProperty("Server","127.0.0.1");
prop.setProperty("Port","27017");
prop.setProperty("Database","testdb");
prop.setProperty("User","useradmin");
prop.setProperty("Password","welcome!");
Connection conn = DriverManager.getConnection("jdbc:mongodb:", prop);
Statement stat = conn.createStatement();
boolean ret = stat.execute("SELECT name FROM users");
It throws error on the last line. These username password are correct and can be used in mongosh inside mongo server container