且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将Android连接到MySQL数据库服务器?

更新时间:2023-02-04 07:51:05

您必须访问使用某种远程方法调用(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.