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?.
Asked
Active
Viewed 6,427 times
2 Answers
2
You can't use second (jdbc) method with android application (SO Reference thread). You have to use REST API.

Community
- 1
- 1

KV Prajapati
- 93,659
- 19
- 148
- 186
-
2can you say why it is not possible?. I think we have JDBC driver in android. – i leaf Mar 28 '12 at 09:48
-
Thanks for your reference link and suggestion – i leaf Mar 28 '12 at 10:20
-
I'm using JDBC in my android studio, I had to do lot of work to make it work, but it does work – aero Aug 29 '16 at 08:48
1
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
Create webservice (REST or SOAP) and invoke it from your device // As you mentioned
Create a Servlet which can service a POST or GET request, and invoke it from your device.
Cheers, RJ

Richie
- 9,006
- 5
- 25
- 38