Reputation: 115
I'm trying to connect to AWS DocumentDB from java application. I think I'm able to connect to cluster, not sure... Because earlier I was getting connection timeout and now I'm not. But now I'm getting the below error
java file
MongoClient mongoClient = new MongoClient(clientURI);
DB db = mongoClient.getDB("giftRegistry");
System.out.println(db);
System.out.println(db.isAuthenticated());
CommandResult commandResult = db.getStats();
System.out.println(commandResult);
Getting error in CommandResult line.
Error
com.mongodb.CommandFailureException: { "serverUsed" : "giftregistry-db.c3ekl0nftuic.us-east-2.docdb.amazonaws.com:27017" , "ok" : 0 , "errmsg" : "Unsupported mechanism" , "code" : 301}
Googled up this, but found nothing.
If there is someone who can help, that would be appreciated..!!
Upvotes: 1
Views: 1341
Reputation: 115
I have resolved the problem myself. Earlier I was using mongo-java-driver-2.12.3.jar, And I was getting error message:unsupported mechanism
. Then I googled up about that and found that SCRAM-SHA-1 is an authentication and authorization mechanism. The MongoDB 2.x
series did not support SCRAM-SHA-1 and there’s no way to make it work. And, SCRAM-SHA-1 is enabled by default in MongoDB versions beginning with the 3.0 series
. So I replaced the jar with mongo-java-driver-3.5.0.jar and It worked out for me
Upvotes: 2