title: How do I check MongoDB 3.0 Client Connection Status with the Java Driver?
body: <p>I am having problems because I only want my code to execute after the MongoClient has successfully made a connection.  But I am having problems finding documentation on this.  Here is my example</p>
  
  <pre><code>MongoClientURI connectionString = new MongoClientURI("mongodb://"+mongoUser+":"+mongoPassword+"@"+config.getMongodbHost()+":"+config.getMongodbPort()+"/"+config.getMongodbDatabase());
          mongoClient = new MongoClient(connectionString);
          goldfishDatabase = mongoClient.getDatabase("goldfish");
  
  System.out.println("Don't print this line until the connection has been made.");
  </code></pre>