title: Is there a way to create a set of X connections to mongodb using MongoClient on application startup?
body: <p>I want to create a "X" number of connections to mongodb on my application startup (i.e before my application starts taking traffic). </p>
  
  <p>MongoDB Version: 4.0.11</p>
  
  <p>Mongo Java Driver Version (maven): 3.4.1</p>
  
  <p>I have tried setting the "minConnectionsPerHost" to the required number, but when i execute the code it barely open 1 or 2 connections. But, when i put load on my application the connection count is slowly going up to accommodate the traffic. I want to create those connections before my application starts taking traffic.</p>
  
  <pre><code>        ServerAddress address = new ServerAddress("localhost", 27017);
          List&lt;ServerAddress&gt; serverAddresses = Arrays.asList(address);
  
          MongoCredential credential = 
          MongoCredential.createCredential("XXXX", "XXXX", 
                "XXXX".toCharArray());
          List&lt;MongoCredential&gt; mongoCredentials = 
                Arrays.asList(credential);
  
          MongoClientOptions clientOptions = 
                MongoClientOptions.builder().connectionsPerHost(100).
                minConnectionsPerHost(50).build();
          MongoClient mongoClient = new MongoClient(serverAddresses, 
                mongoCredentials, clientOptions);
  </code></pre>
  
  <p>Is there a way to achieve this using the mongo java driver?</p>