MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Password e nome utente MongoDb e Morfia

forse potresti usare il seguente codice:

Morphia morphia = new Morphia();
ServerAddress addr = new ServerAddress("host", 27017);
List<MongoCredential> credentialsList = new ArrayList<MongoCredential>();
MongoCredential credentia = MongoCredential.createCredential(
    "username", "dbname", "password".toCharArray());
credentialsList.add(credentia);
MongoClient client = new MongoClient(addr, credentialsList);
datastore = morphia.createDatastore(client, "dbname");