може би бихте могли да използвате следния код:
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");