Home > database >  Java connected mongo, certification services authenticate function can't use
Java connected mongo, certification services authenticate function can't use

Time:09-22

Local Java is directing a driver version 3.6.4 radar echoes captured, authenticate () function cannot be used, have high version to verify the user name and password? Use the connection
ServerAddress ServerAddress=new ServerAddress (ip_address, Integer. The parseInt (port));
List Addrs=new ArrayList<> (a);
Addrs. Add (serverAddress);

//MongoCredential createScramSha1Credential () three parameters respectively user name password database name
MongoCredential credential=MongoCredential. CreateScramSha1Credential (user_name, database password. ToCharArray ());
List Credentials=new ArrayList<> (a);
Credentials. The add (the credential);

//by connecting certification for directing a connection
MongoClient MongoClient=new MongoClient (addrs, credentials);
//to connect to the database
MongoDatabase MongoDatabase=mongoClient. GetDatabase (database);
MongoDatabase. CreateCollection (" test ");
Can't throw an exception, to the perception of the front-end not exception, does anyone know how to get the exception information?
  • Related