Java, Mongo - Start mongo connecting to replica set

March 18, 2016

<![CDATA[ (…) import com.mongodb.MongoClient; (…) MongoClient mongo = new MongoClient(Arrays.asList( new ServerAddress(“<hostname_1>”, <host_port_1>), new ServerAddress(“<hostname_2>”, <host_port_2>), new ServerAddress(“<hostname_3>”, <host_port_3>))); // you may need to use: // Integer.parseInt(“<host_port">) ]]>
SyntaxHighlighter.highlight();