how to connect from android to mysql in nodejs server? - android

I'm making an application, I already have a website nodejs with expressjs framework and mysql database. how to process the input, update and delete data from android to mysql without using php server side? if anyone has ever made before? thank you

Basicly that's what the server side code is doing!
Handling all the data and requests between the two (android app & the relational database)
Any attempt to not use the PhP or any type of language for that matter would cause only to iconically change some data from the app!
But that's not the case since you want to alter also the database as you clearly mention!
As for the how: The only way to use the data transfer to the app is by the use of json packets!
A exchange should be made between the app and the database "through" the server side php code and they should exchange json files with data!
Then your problem is solved.

Related

Connect web app to mysql database

I have a web application on Android and iOS which uses html and javascript for the project. I now have local values and app works fine. now I want to use a mysql database for my inputs, are there any good tutorial or sample codes on how to do that.
I'll appreciate if you can help me with this.
Thanks
For web app and mysql communication need a scripting language like php and for database you need a database like mysql there is simple tutorial fo mysql connectivity
http://www.androidhive.info/2013/12/android-populating-spinner-data-from-mysql-database/
You need to choose a language that will operate server side to manage the database of your web app, e.g. you could use PHP as a language and MYSQL as a database software (it's free and awesome), for examples you could use http://php.net/ and search how to use specific mysql commands in PHP, or use a framework like CodeIgniter which has built in functions for database management and you can view some of them here https://ellislab.com/codeigniter/user-guide/database/active_record.html, but make sure you use the whole user guide on how to use it and how to set up your database configuration properly!
EDIT. If you don't want to use PHP for the actual app then you can use it server side, i.e. use it as part of a server file which connect to database, handle data, send it back, then send it back to your remote app where you can handle it with Javascript.

Update the web database using Android app?

I want to update the database of my website basically android app is getting data from pc it than process it and send it to the web database which store it and when ever android required that data it can get it from that database.
Now my question is how can I send it to the database at a specific place?
Assuming you host the web server hosting the database. You could then package your data (in android) using JSON format, and send the data over using Httppost. Found a good example of code shown in https://fahmirahman.wordpress.com/2011/04/26/the-simplest-way-to-post-parameters-between-android-and-php/ (although the web is just a PHP, you could then expand how to update PHP with MySQL etc). Hope this helps.

How can i connect to MySql database to create a mobile application?

I have a script in java that works like a crawler and saves data in MySql DB. What i want to do is build a Mobile App(Andriod/ios) which will connect to mysql database retrieve results and just show it to the user.
What is the best approach to this ? I tried to use Flex UI with PHP as my server client but was hoping to know if there is a better solution ?
The fastest would be to make android fetch a page in XML, typically on the server and display its contents(If displaying contets is your desired result).
else
You need to implement a script on your server, your POST interacts with that script and inturn that script works with your database.
A typical scenario will be:
Java HTTP POST ~~~> PHP ~~~~> MySql.
PHP will as well help you encode the result in JSON and post it back to your client.
Try using jdbc or jtds library to connect android app with mysql
I used jdts library for connecting mssql db using android app.
http://jtds.sourceforge.net
For mysql jdbc might work

Android SQLite to My MySQL Web Server?

I have been learning SQLite on Android and have done some tutorials on how to use it.
There is a question that I want to ask.
Is there a way to make my app connect to my MySQL database in a remote web server of mine so that it can read data and also write data to the database?
From what I've researched, SQLite cannot be used remotely and I would need some kind of Web service in between?
It's not easy to create a connection to MySQL from Android, if it's not impossible. With that, it's also not safe if for example someone decompiles your app they have access to your whole MySQL database if you don't limit it enough.
For those reasons, you can better use a (for example) PHP webservice to which the Android application sends all their requests. An example is available at http://www.helloandroid.com/tutorials/connecting-mysql-database.
I also suggest you use Android Asynchronous Http Client so you don't have to deal with connectivity issues and AsyncTasks yourself.
You can refer to this tutorial but you do need a web-server for it.
Request mechanism
Android App ----> webserver ------> database (mysql)
Respond mechanism
Android App <---- webserver <------ database (mysql)
Android App will use JSON or other to get the data and display it
You have to use Sqlite database and web Services both. First you have to save the data in local database i.e. SQLite database and then send this data to your server using web services and vice versa.
this link for web services
and this link for SQlite will help you understand.
Thanks.

Cannot populate Spinner with data from remote server database

I am trying to figure out how to populate a Spinner (eventually a whole form of spinners) with data taken from a remote MySQL database. I have read hundreds of examples and tried to replicate them all but to no avail.
I have been working with this example from http://www.mickyjay.co.uk/blog/?p=679
I was never able to get it to work but it seems the most promising out of the lot.
QUESTIONS:
1) Do I need to use a JDBC bridge to connect to the server ? (I was reading that Android does not come with a library to connect to a remote server).
2) I am not looking for someone to do this for me. If anyone has any links to resources that are CLEAR and well documented. I would very much appreciate it.
Since you have MySql database it's good to use PHP to connect to database and send result back to android using JSON response. Android and PHP both support JSON. You can then read JSON and process data as you want in android side. You use HTTP request to run php script. Take a look at this tutorail that shows how to use android, PHP and MySql all together http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

Categories

Resources