android connect to mysql database directly using m

2019-08-02 16:11发布

I am working on an android app and have to use remote database for data storage.I have two options, first create a REST API using php.Second option is connect directly to mysql db with JDBC using mysql-connector-java-5.1.18-bin.jar. I am not familiar with second one but i want to confirm which method will be feasible and why?.

2条回答
相关推荐>>
2楼-- · 2019-08-02 16:58

You cannot use normal JDBC connection method to a remote to a db server from your android phone as you do normally in a Java application. This is because Java application normally runs a machine which is either on a network or can connect to a network or has the mysql database on it which is not the case with your android phone.

The alternatives you have are

  1. Create webservice (REST or SOAP) and invoke it from your device // As you mentioned

  2. Create a Servlet which can service a POST or GET request, and invoke it from your device.

Cheers, RJ

查看更多
小情绪 Triste *
3楼-- · 2019-08-02 16:59

You can't use second (jdbc) method with android application (SO Reference thread). You have to use REST API.

查看更多
登录 后发表回答