I'm working now in an android application which will get the some data from MS sql database. I used jtds jar file to connect to the database, but I read that connecting to database from the application directly is not secure and I should use a web service. but I can't understand why?! .. can some one help me?
Also, I found a lot of tutorial explaining the connection using a web service using REST. But all of them depends on I have a php file then send HTTP request then parse json string. So should I create this file myself!
You should never connect to a database from within your app, because in order to do so you are embedding your database credentials in your application. Which means that anybody with a decompiler can get those credential and do what they please to your database with that.
here's an example of what happens when you do that =)
http://gamingirresponsibly.com/team-meat-learns-a-hard-lesson-by-hackers
Related
I have a javafx app that i created and it makes calls to the mysql database. Unfortunately the database username and password is viewable if you view the jar files. Is there a way to have the javafx app connect to a PHP file on my web host server to manage these database calls and database connection so I do not need to store the creds client side? Or is there a better way to handle this server side? Maybe an API?
Uploaded picture of what I mean
The first thing you should determine is the data that you want to read/write using your java application. Only that data that it needs.
The second is why do you beware of revealing storage access credentials? Is it because of data that shouldn't be visible from the java application?
If an application has access to data hance the owner of the application has access to data. No other options here. The only thing you can do here is to restrict access for each application to its data. It means that each application should have its own credentials which give access to that application's data.
It doesn't matter if you use either MySQL direct connection or API. In both cases, you have some access credentials (DB login+password or API token) or don't have credentials at all but the last one means everyone will have access.
I am just a beginner in android app development and that's why I have many doubts. I am building one application where the user enters some data in editText. Now I want to save that data in my database. My database is running on my laptop. How would my app connect to the database? Do I need a web server in between? If yes then which web server is used for Android apps? Basically, i want to know the flow of data from app to the database.
Study more from Udacity.com, its free.
You may use a jdbc Connector to connect to database.
Connect your jdbc connector over local network ip\servername and database connection string
You can use REST Service when it comes to web Service on Android like this. You can either pass the values as parameters or an Object depending on your requirement. All the best
Wamp server is best option to play with server related utilities.You can use it even if you are offline. and it provides various option for data storage. It Mainly uses MySql and PHP scripts for fast performance.
For More details Click Here
Any tutorials out there on how to send and received data to and from a MySQL database hosted on a server using cPannel? I'm trying to make an android app that connects to the internet, and it needs to read and write data to and from the hosted database. The database is a MySQL one and is hosted on godaddy. I've been on the internet all day today looking, so any help would be greatly appreciated.
Well you need to write a webservice which will get the data from your mysql database and send it to your android app.
First of all you need a server which you have already. Create space to write php scripts there to interact withe the database that is hosted there.
Second Write a php script on your server which can retrieve the required data from the MySQL database. Encode the retrieved data inside a JSON object and send it back to your app. From your app you have to call the URL where the webservice is hosted, and the php script will do the interaction with the database, retrieve the results and send it back to your app in JSON.
Third - Follow the same method to send and retrieve data to server. Create multiple webservice as per your requirements.
This tutorial excellently illustrates what you are looking for. This example uses a local server. You can skip some of the steps there. Hope it helps. URL: http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
If you still got any questions, comment below. I will be happy to help.
Thanks!
First, I'd like to let you know my experience.
PHP - medium | Android/Java - medium | JSON - low | MySQL - low
I'm trying to make an app that will be able to connect to a MySQL DB, grab a specified row, and display it in my application.
I've been doing a lot of research, but feel like I still have a lot of unanswered questions. From what I read that doing a direct connection to the database should never happen. Is this true? Next, most people suggest writing something in php to connect the app to the database. My main question is where do I put this php code? On a website or in the android app (if that's even possible)?
If anyone has experience with this, do you think I should follow this tutorial? (I don't want to buy a domain if I don't have to)
http://www.helloandroid.com/tutorials/connecting-mysql-database
Client side:
and android app that basically uses the defaulthttpclient in java to establish connection to a php page hosted on a website by posting data to it(httppost).
and a json parser to read the retrieved data and display it.
server side:
a php script on the web server which accepts post data from the client, and retrieves data from MySQL database at the server and displays it, which can be read by the client as an httpresponse.
i hope that helps.
Create a web service to pull objects that contain data from your database. A WCF Service is a good choice.
How can I connect my local database in my application? I have a database which contains a book. I have to display it in my application in J2ME
Basically, in JME, an app can create a database which is a file stored in the RMS. Actually, there are several APIs that can help you in creating a Java ME database: Is there any option for local database like Sqlite for j2me - CLDC devices?
Anyway, I think the data in a sqlite database is not easily accessible to a JME app. It is not impossible but it, maybe, is complicated. Honestly, I don't know anyway to do it.
You have to create a server application where you access to database. Also your J2ME has to communicate with your server application for getting Data you want to display (Use HttpConnection Class).
In Mobile Application, you can not directly make connection with local or remote database. To Make Connection with Database , you need a middle tier called a web service. You can create web service in any platform like Java-Servlet, .net or in PHP. See this is a very simple example to work with MySql Database.