Issue
I just set up a Maven project with the Mongo Java driver and everything, but when I run
public static void main(String[] args) {
MongoClient client = new MongoClient("localhost");
MongoDatabase db = client.getDatabase("test");
}
trying to connect to a mongod instance from the command line, it gives me
INFO: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
in the console and doesn't connect. I pretty much followed everything from this tutorial.
Solution
@Oleg Skylar was right, there was actually nothing wrong with my program in the first place, it's just that I was using outdated methods to test whether it was working. Once I followed https://docs.mongodb.com/getting-started/java/query/ to query for test data, it worked.
Answered By - Matthew Park