title: Use properties to parameterize connection to Mongodb
body: <p>I am trying to use Properties file to parameterize connection to Mongodb.</p>
  
  <p>I have added this function:</p>
  
  <pre><code>public static Properties load(String filename) throws IOException, FileNotFoundException{
    Properties properties = new Properties();
  
    FileInputStream input = new FileInputStream(filename);
    try{
       properties.load(input);
       return properties;
    }
       finally{
       input.close();
    }
  
  }
  </code></pre>
  
  <p>and use this code:</p>
  
  <pre><code>    String path = System.getProperty("user.dir") + "/config.properties";
      Properties prop = load(path);
  
      //System.out.println("key: "+ prop.getProperty("MONGO_HOST"));
  
  
      try {
  //m = new Mongo(config.MONGO_HOST, config.MONGO_PORT);
      m = new Mongo(prop.getProperty("MONGO_HOST"), config.MONGO_PORT);
  this.db = m.getDB("cloud_datasource");
               db.authenticate(config.MONGO_USER, config.MONGO_PASS.toCharArray());
      } catch (Exception e) {
  System.out.println("Can't connect to MongoDB");
               e.printStackTrace();
  
      }
  </code></pre>
  
  <p>In my config.properties: <code>MONGO_HOST="192.168.10.84"</code></p>
  
  <p>Problem: with this code, I have an error <code>java.net.UnknownHostException: "192.168.10.84"</code>
  but if I am using the code:</p>
  
  <pre><code>m = new Mongo("192.168.10.84", config.MONGO_PORT);
  </code></pre>
  
  <p>it works.</p>