1

I first successfully connected via JDBC to a remote MySQL server with a Java program. That I understand how to do. My goal is do the same thing with an Android application and display data from a remote MySQL server.

Question 1 Can someone explain the process outline to do this via Android ? (I am new to Android and am a little stronger with Java, could use a little guidance).

Question 2 I found this tutorial on javatutorialpoint.com titled: Android MySQL Client but it wants me to use the SOAP API. Not sure why, if someone could explain.

Not asking for it to be done for me. I just want someone to outline the main steps in order to make it happen. Just the process that needs to occur is all I am asking.

Dee129
  • 91
  • 2
  • 6
  • JDBC is designed for highly-reliable, high-speed network connections. Mobile devices have highly-unreliable, variable-speed network connections. I would not recommend that anyone directly communicate from an Android app via JDBC to a remote database. Use a Web service backed by the database instead. – CommonsWare Mar 19 '13 at 21:47

3 Answers3

2

Question #1:

I stumbled upon this link some time ago:

http://docs.oracle.com/cd/E17076_02/html/installation/build_android_jdbc.html

(Disclaimer: I haven't read the whole tutorial myself)

It tells you what's needed for getting the MySQL connector to work with Android.

Basically, from what I know, the standard MySQL connector for Java, doesn't work out of the box for Android. You'll need to build it on your own.

After building the connector, you can include it in your Android project, precisely the same way as you do in a normal Java project.

Your Question #2:

SOAP is a mere layer of abstraction, for not working directly on the database. If you use a layer like SOAP, you can swiftly change your database layer without affecting much of the communication from-and-to the Android app.

Darwind
  • 7,284
  • 3
  • 49
  • 48
1

You can use the same methods in Android you used in Java (Android is written in Java, after all, and you are able to use the majority of its libraries in android). However, be careful with doing so.

It would probably be better from a security standpoint to set up a web service to communicate with the database, rather than you allowing your android app to communicate directly with it, which would actually require you to embed your mysql username and password in the app code. A SOAP or RESTful web service could enable your server to communicate with the DB and then serve the data from it to your app.

drew moore
  • 31,565
  • 17
  • 75
  • 112
  • Security through obscurity is not a good idea, same as over-design is not (don't try to solve problems you don't have). And Android is not a *flavor* of Java. How can an OS be a flavor of a programming language? – m0skit0 Mar 19 '13 at 21:37
  • 1
    @m0skit0: "Security through obscurity is not a good idea" -- using a Web service front-end to a database is not "security through obscurity", by any conventional definition of that phrase. "over-design is not" -- using a Web service front-end to a database is not "over-design", by any conventional definition of that phrase. – CommonsWare Mar 19 '13 at 21:45
  • Using a web service *for the sole purpose* of hiding the username/pass of DB **is** security through obscurity by its very own definition (hiding stuff will increase my app security). And if using a web service as front-end is not over-design, why not always use a web service instead of JDBC? When to use JDBC then? – m0skit0 Mar 20 '13 at 10:36
0
  1. It's done the same as in Java (Android apps are build in Java unless you're using the NDK).
  2. You don't need SOAP if you only want to get data from a remote DB.

See this question.

Community
  • 1
  • 1
m0skit0
  • 25,268
  • 11
  • 79
  • 127