How Connect to Remote MySQL server through Android App via JDBC - java

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.

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.

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.

It's done the same as in Java (Android apps are build in Java unless you're using the NDK).
You don't need SOAP if you only want to get data from a remote DB.
See this question.

Related

Android connecting to Java Server

I'm new in android studio I'd like to know how can I make requests to a server.
I wanted that in my Android App I sign up an account and my server stores all the users, something simple just to start. The next step that i want is like passing some strings or objects to other users.
How can I do that?
Is recommended to do my Server in Java/Python?
Thank you
I would suggest you first google your queries, since there are many such repositories on GitHub.
First Link when I searched Android CRUD was this
https://github.com/budasuyasa/simple-android-crud
As for Java or Python, all depends on your skill set, what I would recommend is using Spring boot for backend services but you can also use Flask to create Rest services in Python.
Have fun coding

JavaFX application with remote DB

I'm developing a desktop application in JavaFX with login system and some data that must be saved in a remote database. The question is: What it's the best way to stablish a database connection with each user with the server? Should I use a RESTful API or connect to database using the remote host just like if it was a local DB?
What kind of data are you looking to manipulate? Depending on exactly how much control you may need over the information (and how secure it must be?) if you don't need an absolutely synchronized view of the information (re: the server side app having a persistent connection to the client which is informed on change events and such) it may be best to just build up a RESTful API to do all of your grunt work between the two.
If you're coming to the RESTful api and also have to design it I suggest giving this a good read. Best Practices for a Pragmatic RESTful API

How to access SQL database with Web App and Android App

What is the best way to have a SQL database that can both be accessed by an android device via java code and by a web app via php code?
In my mind I imagined a MySQL database somewhere on the cloud that is accessed in all the normal ways by the web app using mysqli_connect and then somehow the same database calls are made in Java inside the android app.
But after some research it appears this may not be the way to do it. What is the way to do this correctly?
EDIT: It was suggested my question was too broad. What I want then is a database of some basic financial information which is stored on the cloud which is then able to be accessed via a web app written in the LAMP stack and via an android app (with java code).
It is a really simple problem but I am not sure what the best practice for such a problem is in android (I come from a web dev background)
The standard way to access a database for mobile application is different than a normal web page/application.
Mobile devices should never run queries in the database; What you do is create a web service that does all the queries in the database and then sends back HTTP responses in xml, JSON format to the mobile device for consumption.
At the same time you can create a web client that interacts with the web service the same way your mobile app does. This way if you get erroneous data you can debug the web service without having to recompile the code in the mobile app.
Do a Google search for restful web service

connect to Neo4j through Android - impossible task?

Is there any way I can connect to a remote Neo4j server from an Android Project at all ? I have used several approaches: JDBC driver and through REST API using Jersey Client however none of these approaches are successful. All of these work in a pure Java project but fail miserably in Android. At this stage I lost hope that there exists a way I can talk to the database through android. Is that feasible or am I wasting my time trying to find impossible solution ?
If Neo4j exposes an HTTP REST interface, then yes of course you can access it from Android. There are many different ways, including HTTPUrlConnection and Apache HttpClient.
If you want to use Jersey, there's no reason why that wouldn't work. I'd start with one of the above first though to prove to yourself that the basics work.
Here someone as written a Java binding to the REST API.
https://github.com/neo4j-contrib/java-rest-binding
You can use (most) Java libraries in Android.

Help regarding What DBMS to use for interaction between android phone, server and database?

I am looking for some guideance in terms of what database to use server(using servlets) side of my android application.
Further down the line i will setup a website that will need to access the information from with the database.
At the moment from what i know i can use hibernate for object mapping to RDBMS or i can use JDBC for interaction with a MySql Database.
Do you guys have any best practices for using either the above or a different system for interaction between servlet and database?
If you are looking to get started quickly, you could use AppInventor, but if you want to build a backend yourself I suggest Ruby on Rails(get ubuntu if you don't have it!). Its easy to learn, easy to install, and very user-friendly.
The server and database will be handled by the Ruby on Rails framework.
Android application just acts as a client that makes request and accepts response from a Server. Server could be written using Servelets / JSP, ASP or PHP. As far as I know it doesn't matter to android client which database server is used at the server side as far as client is getting the response from the server.

Categories