(需要咨询)从我的Andr​​oid应用程序与MySQL服务器数据库我的、应用程序、服务器、数据库

2023-09-12 21:39:06 作者:詯╮吥媞傳說

我开始我的论文这是Android的应用程序。这个程序是基于我创造了一个网络平台。

I am starting my thesis which is an app for android. This app is based on a web platform I had created.

在这里我需要咨询的部分是:这是从一个MySQL服务器到应用程序中提取数据的最有效方法。请给我一些建议和您对此事的经验。的

The part where I need advice is: which is the most efficient way to pull data from a MySQL server into the application. Please give me some advice and your experience on the matter.

(我读过有关编码的JSON的查询,但它似乎是非常多的不必要的工作)

(I've read about encoding the queries in json, but it seems like awful lot of needless work)

推荐答案

我建议你在使用基于REST的Web服务使用Java的的球衣,你的Andr​​oid应用程序和MySQL服务器之间的中间层。您可以在JSON(我的建议的移动应用程序),XML或佩林文字到您的Andr​​oid应用程序。

I suggest you to use RESTful Web Service in Java using Jersey as an intermediate layer between you Android App and MySQL server. You can transfer data in JSON (my suggestion for a mobile app), xml or palin text to your Android App.

您可以在您的@Elad答疑系统使用Web服务的好处:Best的方式来访问远程数据库:通过Web服务或直接DB访问

You can find the benefits of using Web Service in you system in @Elad answer : Best way to access a remote database: via webservice or direct DB-access?

另外以后如果你决定要开发其他智能手机平台,为你的系统,你只需要重复使用相同的Web服务。其结果是该Web服务可被认为是一个通用的协议的系统中的移动用户。

Also later if you decide to develop other smart phone platform for your system, you just need to reuse the same Web Service. As a result this Web service can be considered as a generic protocol for the mobile user of your system.

我用Hibernate来映射数据到MySQL数据库。 RESTful服务使用新泽西州与Hibernate持久

I used Hibernate to map the data to MySQL database. RESTful Service Using Jersey with Hibernate Persistence

如果您决定采用这种方法需要注意的是,强烈建议分开你的Hibernate的东西形成你的球衣服务。你需要连接你的DAO到你的服务层。看看@Rick Mangi写信给我:使用 REST与Java(JAX-RS)新泽西州和休眠

If you decide to follow this approach note that it is highly recommended to separate your hibernate stuff form your Jersey services. You need to wire your DAO to your Service tier. see what @Rick Mangi wrote to me : REST with Java (JAX-RS) using Jersey and hibernate

这也是使用HTTP客户端在你的Andr​​oid应用程序很好的方法,因为它支持@GET,@POST,@DELETE和@PUT命令,你可以很容易地与你的数据库像HTTP GET请求

It is also good approach to use HTTP Client in your Android App, Since it supports @GET, @POST, @DELETE and @PUT commands and you can easily talk to your database like HTTP GET Request