如何到Android与MySQL使用MySQL JDBC驱动程序连接

问题描述:

我想从表中的数据在MySQL中,并显示出它的TextView,但我有一些问题,当我尝试与数据库连接。
我使用的Eclipse为Android,当我尝试在Java项目从MySQL数据一切正常,但是当我使用的Andr​​oid项目这是行不通的。
有谁知道使用MySQL JDBC驱动程序与Android项目我该怎么连接MySQL?
或者给我其他方面的建议如何与MySQL连接的Andr​​oid项目?

I want to get data from table in MySQL and to show it in TextView, but I have some problems when I try to connect with database.
I'm using Eclipse for Android, and when I try to get data from MySQL in Java Project it works, but when I use Android Project it doesn't work.
Does anyone know how can I connect MySQL with Android Project using MySQL JDBC driver?
Or to give me other advice how to connect Android Project with MySQL?

Android的默认情况下不支持MySQL。它有一个内置的数据库即SQLite的。 如果你想远程访问MySQL数据库,你应该揭露接口到这个数据库与任何标准Web服务。 例如,您可以创建在其上使用Java / PHP等和MySQL连接器编写服务器端基于REST的Web服务。 (你已经做了!) 而你的Andr​​oid应用程序可以跟这个服务的URL使用此Web服务生成。

Android by default does not support MySQL. It has an in-built database i.e SQLite. If you are trying to access MySQL database remotely, you should expose interface to this database with any standard web service. E.g you could create RESTful Web Service on Server Side which is written using Java/PHP etc. and MySQL Connector. (Which you have already done!) And your Android App could talk to this service with the URL generated using this web service.

此外,这个问题一直重复previously,这样你就可以检查这些解决方案。

Again, this question has been repeated previously, so you can check those solutions.