I use Java and MongoDB in the Google engine, but I cannot find links on how to connect to MongoDB with Java.
I tried the following:
Maven:
<dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.6.3</version> </dependency>
Java:
String serverName = ""; //provided external and internal ip addresses as well as name of mongoDB instance, Mongo mongo = new Mongo(serverName); //com.addsapp.dao.MongoDB.initDB1(MongoDB.java:39)
And got the following result:
Uncaught exception from servlet java.lang.ExceptionInInitializerError at com.mongodb.Bytes.<clinit>(Bytes.java:215) at com.mongodb.MongoOptions.reset(MongoOptions.java:32) at com.mongodb.MongoOptions.<init>(MongoOptions.java:28) at com.mongodb.Mongo.<init>(Mongo.java:175) at com.mongodb.Mongo.<init>(Mongo.java:140) at com.addsapp.dao.MongoDB.initDB1(MongoDB.java:39) ...
Does anyone have a good Java link on how to do this? Could not find anything on tzhe netz.
Thanks.
source share