7

I want to connect a MySql DB with my android application.
However, I DON'T want to/CAN'T use PHP for doing this.

Almost all solution for MySql connection with android on internet uses PHP.
I read somewhere that, If one don't want to use PHP then web service should be used.

But I'm not able to find any tutorial/sample example for the same.

Any help appreciated.

1
  • 2
    Instead of just down voting, kindly let me know the reason/ solution. Commented Jan 3, 2013 at 10:08

4 Answers 4

3

It seems you're mixing up some things.

A web service is simply some code on the internet (web) which allows you to receive and send information to a server, where it is saved per example in a database.

PHP is just a language, in which you can write a web service.

You can use a vast array of languages to create a web service ( read: expose your database) to other devices. Among others, you can easily do this in Java, .NET, Python ...

If you're looking for a way to connect to an external database without any web service / API in between, i'll have to disappoint you with the news that this is not supported by Android.

Most examples of a simple web service / a bunch of scripts contain PHP since this is probably the easiest and can be used on pretty much any server.

Sign up to request clarification or add additional context in comments.

2 Comments

but PHP requires wampserver na?
so if I don't want to use PHP at all, I should write a web service in Java to connect to MySql? Will it require anything else (any external server or tool)?
2

A webservice, is as it's called, a service, meaning that you have one side consuming it (the android client). if all you want is a persistent storage, you could use SQLite which is an SQL compliant solution which exists within android.

If it's possible to SSH to a server via Android, you could use that to connect to mysql, because the only other solution involves having mysql binaries installed locally on your android machine, and that's not possible AS FAR AS I KNOW, on Android.

Comments

1

One major reason for using a webservice (e.g. written in PHP) to connect to a remote DB is that you don't want to store the database login credentials inside your app. Because otherwise it'll be easy to extract your login for that database and access and edit it in a way you might not have planned (eg. delete stuff).

5 Comments

can that web service be written in Java also?
That would absolutely be possible, yes. It would just receive the requests from your app (in what form ever), should check if they are valid/legal and submit a MySQL query. I think most tutorials just mention PHP because that's most popular with MySQL – but you could use whatever language you want for your webserver.
Did this answer your question or are there still any obscurities?
m constantly facing connection difficulties while connecting mysql to android... it's giving Incorrect syntax,privileges,etc. exceptions
Did you see this question (and the answer of Kurian)? Because if you really dont want to use a webserver JDBC seems the way to go: stackoverflow.com/questions/4447692/jdbc-connection-in-android
-1

Its Possible to connect mysql database .

I have done with out using php file . I have used an spring configuration file to establish an connection to the database and dao to access the data from the database.

Create an Web Application that access the Server through the Spring Framework and an Servlet .

Create an Android Client Application tat make an get / post request to the Servlet , process the results in the servlet and return the response to the Android Client Application (json format ) Process the json format reponse in the Android Client Side and use it to your application

1 Comment

Been a long time but, the same with the default php solution only with Spring and Servlet. wish there was another way

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.