(need advice) Talk to MySQL server database from my Android App

前端 未结 2 1278
渐次进展
渐次进展 2020-12-02 00:22

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

The part where I need advice is: which is the most effici

相关标签:
2条回答
  • 2020-12-02 01:00

    Perhaps, by using a MySQL Java connector, and directly connect to the server over port 3306 using the Java's JDBC connector as a Jar library imported into your Android project, as shown here, and also this was blogged a good while ago

    0 讨论(0)
  • 2020-12-02 01:16

    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.

    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?

    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.

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

    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

    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

    0 讨论(0)
提交回复
热议问题