try
{
// TODO: Create one of these per collection? Really? Perhaps I should cache.
MongoClient mongoClient = new MongoClient(muri);
DB db = mongoClient.getDB(muri.getDatabase());
if (muri.getUsername() == null) return db;
if ( ! db.authenticate(muri.getUsername(), muri.getPassword()))
{
//log(Level.SEVERE, "... db authentication failed.");
return null;
}
return db;