I'm about to build a project in Play Framework for Java 2.1 and I would like to use MongoDB to store data. I've installed both Play 2.1 and MongoDB 2.4.4.
Is it possible to build a Play! project with only the MongoDB Java Driver? I've actually tried to download the mongo-java-driver.jar
which I placed in a lib
/ folder in the root
of my play project according to this documentation. Then I've created a model in which I've added the code below but I can't get it to work. Do you know any tutorials or what am I doing wrong? I get compilation errors like unreported exception java.net.UnknownHostException; must be caught or declared to be thrown
import com.mongodb.MongoException;
import com.mongodb.WriteConcern;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.mongodb.DBCursor;
import com.mongodb.ServerAddress;
MongoClient mongoClient = new MongoClient();