JuiCe
JuiCe

Reputation: 4201

Connecting to a MongoDB with Android in Eclipse

I am currently developing an Android application, which is going to use a database from MongoLab. Another member of my team has already created a working database on mongolab.com, I am just having trouble connecting to it via Eclipse.

I have looked all around Google and at countless tutorials, but I really don't know much about what I'm doing.

The best tutorial I have found is from mkyong.com. It seems the second section labeled Java MongoDB Examples is what I am looking for, but I cannot get the library being used in those examples imported into my projects.

Is there a URL I can search for in Help >> Install New Software in Eclipse? I have downloaded the mongo-java-driver, but do not know how to incorporate that into my Eclipse.

To clarify again, I have no need to create a MongoDB, I am just trying to connect to an existing database via an Android project in Eclipse.

Upvotes: 3

Views: 4426

Answers (3)

matfur92
matfur92

Reputation: 330

Java Mongo driver 2.6 is compatible with Android.

The actual version 3.0.3 isn't compatible with Android because javax.security.sasl.* isn't implemented on Android.

I'm working on a forked version of 3.0.3 adding javax.security.sasl classes of this project https://github.com/koterpillar/android-sasl

Upvotes: 0

Ranjodh Singh
Ranjodh Singh

Reputation: 1

I think you need to use the rest API provided by the Mongo Lab , not the java API. Send Http call to the server and get the response and parse it using JSON Parsor, that should do it.

Upvotes: 0

Uku Loskit
Uku Loskit

Reputation: 42040

You must add the driver jar to your CLASSPATH, please refer to this FAQ.

If you have done this correctly Eclipse should be able to provide import for the the Mongo class if you type something like:

Mongo mongo = new Mongo("localhost", 27017);

Upvotes: 1

Related Questions