I'm using Java and MongoDB on google app engine but I cant find any reference on how to connect to MongoDB with Java.
I've tried with 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 reference on how to do this? Couldn't find anything on tzhe netz.
Thanks.
You can't. You have to use the storage options given, like the datastore. You could connect via a web interface of course to an external instance, but I don't think that's what you are asking.
Take a look at compute http://googlecloudplatform.blogspot.co.uk/2014/06/running-mongodb-on-google-compute-engine.html
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加