连接到与Android一的MongoDB在Eclipse [英] Connecting to a MongoDB with Android in Eclipse

查看:275
本文介绍了连接到与Android一的MongoDB在Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个Android应用程序,这将使用从 MongoLab 的数据库。我的团队的其他成员已经创建了 mongolab.com ,我只是有通过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.

我发现,最好的教程是从 mkyong.com 。这似乎标示的第二部分 Java的MongoDB的例子是我期待的,但我不能让那些进口到我的工程实例所使用的库。

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.

有没有我可以在搜索网址帮助>>安装新软件在Eclipse?我已经下载了蒙戈-Java的应用程序,但不知道如何将那到我的Eclipse。

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.

要再次澄清,我没有必要创建一个的MongoDB ,我只是想通过在Eclipse中的Andr​​oid项目连接到现有的数据库。

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.

推荐答案

您必须将驱动程序的jar添加到您的CLASSPATH,请参阅本的常见问题

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

如果你这样做了正确的Eclipse应该可以,如果你输入像以提供蒙戈类导入:

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);

这篇关于连接到与Android一的MongoDB在Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆