如何将Android连接到MySQL数据库服务器? [英] How to connect android to MySql database server?

查看:186
本文介绍了如何将Android连接到MySQL数据库服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我有一个Android手机连接到远程MySQL数据库服务器,将数据插入到数据库并获取数据过来。

In my project, I have to connect an Android mobile phone to a remote MySQL database server, to insert data to the database and get the data back later.

不过,似乎Android操作系统仅支持SQLLite数据库,手机内本地工作。

However, it seems that Android OS only supports the SQLLite database that works LOCALLY inside the phone.

有谁知道如何将Android手机连接到远程MySQL(或MSSQL或Oracle)数据库服务器?

Does anyone know how to connect an Android phone to a remote MySQL (or MSSQL, or Oracle) database server ?

感谢您!

推荐答案

您必须访问使用某种远程方法调用(RMI)。

You will have to access the database using some sort of Remote Method Invocation (RMI).

我个人的建议是建立一个RESTful HTTP接口的服务器上的MySQL数据库。这可能是更多的工作,但pferred的易用性和兼容性与任何系统$ P $(,可以使这是一个HTTP请求)。

My personal recommendation is to create a RESTful HTTP interface to your MySQL database on the server. This may be a bit more work, but is preferred for its ease of use and compatibility with any system (that can make an HTTP request that is).

从本质上讲,你应该创建HTTP端点创建,读取,更新,删除服务器上的MySQL数据库(CRUD)数据。你的Andr​​oid客户端会再打电话给这些HTTP端点来执行相应的CRUD操作。当然,你并不需要做典型的CRUD操作,你可以让你的端点与数据库进行交互不过你的愿望。

Essentially, you should create HTTP endpoints to Create, Read, Update, Delete (CRUD) data from your MySQL database on your server. Your Android client would then make calls to these HTTP endpoints to perform the corresponding CRUD operations. Of course you do not need to do the typical CRUD operations, you can make your endpoints interact with the database however you wish.

就像我说的,一个很大的优势,这是多么可扩展性。您可以创建其他客户端,在其他系统上,用另一种语言,和所有你需要做的是进行正确的HTTP调用。

Like I said, a big advantage to this is how extensible it is. You can create another client, on another system, in another language, and all you need to do is make the proper HTTP call.

这篇关于如何将Android连接到MySQL数据库服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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