1

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..!!

2
  • DB db = mongoClient.getDB("giftRgistry") might be giftRegistry?? is that typo or the reason of the error? Commented Oct 9, 2019 at 9:21
  • It's a typo.. updated the same Commented Oct 9, 2019 at 11:24

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.