I'm trying to connect to a mongolab host server. The database collection is defined and I can add and view entries trough the shell.
However I cant seem to get to view the entries in eclipse. I get an exception in thread "main" error unresolved compilation problem. The editor shows at the new MongoClient(uri) line - Unhandled exception type UnknownHostException error. How do I fix this?
String mongolabUri = "mongodb://username:password@dsDATA.mongolab.com:DATA/database";
MongoClientURI uri = new MongoClientURI(mongolabUri);
MongoClient client = new MongoClient(uri);
DB database = client.getDB("database");
DBCollection collection = database.getCollection("testcollections");
DBObject document = collection.findOne();
System.out.println(document);