może mógłbyś użyć następującego kodu:
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");