title: MongoDb and morphia password and username
body: <p>playing around with this and cannot get a grip<br>
  on how to connect with password.  </p>
  
  <p>In MongoDb it's quite easy to understand but when i use morphia it's not<br>
  so quite obvious because documentation is minimal or i missed it.  </p>
  
  <p>I already have a Collection with 5 documents.<br>
  Can i apply a user/pass on that one?  </p>
  
  <p>How can i modify this code so logging uses a username and password?  </p>
  
  <p>Took the code from this post (Thanks @Lennart Koopmann)<br>
  <a href="http://www.lennartkoopmann.net/post/722935345" rel="nofollow">MongoDB Java driver tutorial</a></p>
  
  <pre><code>public final class MongoConnectionManager {
  
   private static final MongoConnectionManager
   INSTANCE = new MongoConnectionManager();
   private final Datastore db;
   public static final String DB_NAME = "mongo_database";
  
   private MongoConnectionManager() {
              try {
                  Mongo m = new Mongo("localhost", 27017);
              db = new Morphia().map(UserData.class)
       .map(Statistic.class)
       .map(FriendList.class)
       .map(ServerData.class)
       .map(BatchData.class).createDatastore(m, DB_NAME);
  
                  db.ensureIndexes();
              }
              catch (Exception e) {
                  throw new RuntimeException("Error initializing mongo db", e);
              }
          }
  
          public static MongoConnectionManager instance() {
              return INSTANCE;
          }
  
          public Datastore getDb() {
  
              return db;
          }   
      }
  </code></pre>