开发者

Android/MongoDB: "NoClassDefFoundError: com.mongodb.DBPortPool"

I'd like to connect to my MongoDB (hosted on MongoHQ). I get the following error when I want connect to the database (with the Java driver)

ERROR/AndroidRuntime(597): java.lang.NoClassDefFoundError: com.mongodb.DBPortPool
ERROR/AndroidRuntime(597):     at com.mongodb.DBPortPool$Holder.get(DBPortPool.java:52)
ERROR/AndroidRuntime(597):     at com.mongodb.DBTCPConnector._set(DBTCPConnector.java:380)
ERROR/AndroidRuntime(597):     at com.mongodb.DBTCPConnector.<init>(DBTCPConnector.java:46)
ERROR/AndroidRuntime(597):     at com.mongodb.Mongo.<init>(Mongo.java:138)
ERROR/AndroidRuntime(597):     at com.mongodb.Mongo.<init>(Mongo.java:124)
ERROR/AndroidRuntime(597):     at com.mongodb.Mongo.<init>(Mongo.java:114)
ERROR/AndroidRuntime(597)开发者_如何学编程:     at xxx.MainActivity$1.onClick(MainActivity.java:29)

I use the following code:

Mongo mng = new Mongo("flame.mongohq.com", 27073); // <- error
DB mngDb = mng.getDB("xxx");
mngDb.authenticate("xxx", "xxx".toCharArray());
DBCollection mngColl = mngDb.getCollection("xxx");
// mText.setText("Data Count: "+Long.toString(mngColl.getCount()));

I added the driver in Eclipse via Properties>Java Build Path>Libraries>Add Externel JAR


This driver does not support android...


The DBPortPool has a dependancy on JMX however JMX is not supported on android.

Out of interest, what is your use case? As you will want to avoid passing database username/pwd from your phone without security infrastructure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜