I simply have a small question..
I was wondering about Android connection with MySql , As I know there is no any direct connection between Android with MySql, we need to use JSON or any other library to connect. Well using JSON and configure it with some PHP files, is this the only way we can get and query datas from mysql,so far, and is it desirable this way??? or there are some other way how to get the datas from mysql into listview or wherever in Android?
Thanks,
You can deploy the mysql JDBC driver into your Android application. There are several blogs that show you how to do it. How functional it will be I can't tell. Just keep in mind that if you want Android devices to connect to your mysql server directly you need to expose the mysql server to the internet directly. This is generally not recommended. Also the data flowing between mysql and the device will be unencrypted.
Essentially doing this moves your architecture back to client server model. If you later wanted to support iPhones, blackberry or Windows mobile you will have to make those devices also connect directly to mysql. By using a webservice or even your own custom developed server you can remove the dependency on the MySQL driver. In the long run this will probably be a better model to follow.
The choice is yours however.
Related
I wand to access the postgreSQL database from android using Pydroid3 application in my mobile phone. to access postgreSQL database i need to import psycopg2, but android doesn't support this.
can anyone please suggest the way to solve this issue.
With Android you typically don't make a hard database connection, unless its a local one.
psycopg2 doesn't work for the same reason you're not supposed to use JDBC . You should talk to a remote database via a RESTful API, meaning a server sends you data that it itself retrieves from the database.
So your next step would to create a web site/service that handles GET requests. So your app can talk to it, and it can talk to the database.
I am new in android development. I am developing android app for news portal. I want my users to be able to read news even when there is no Internet connection, somehow similar to twitter feed. I need advice about connecting server data from SQLite. I see two options for now: connecting directly to MySQL or generating XML data in server in /rss page and synchronize using scripts. Which one will be better? Or is there any other option?
SQLite is best solution for this problem. We need to put synchronization technique between SQLite and MySQL.
Am developing Android program. Now I need to access MSSQL2008R2 remotely from one computer(client) to another computer(server).
Which is the best way to connect?
Such as, JDBC Driver, Web Service
If you developing the the mobile application for any OS like Android, iPhone, Blackberry etc. then you should use web service to get data from server.
Reason to use Web service.
If you use web services method to get the data from database server remain same and need to write once in webservice but in case of JDBC its only for java, In other cases you need to search other ways to connect to database server.
I am trying to create an Android app similar to google latitude and I am not sure what to use in terms of databases. I thought of using SQLite (which is serverless), but I still need a server in order to make two clients communicate to each other. I am really new with connecting an app with a server or a database, so any help would be appreciated.
I dont believe there is a way to remote connect to any database from Android (could be wrong, but when I check it wasnt possible). Your going to have to use SQLite for your local, and i recommend using MySQL for the server side, and use JSON to retrieve information via a service page.
OK, what you want to do is a client-server architecture. You need to think about what kind of data you want to store, and where to do that.
Obviously, on the server side, you need to store data. It will depends what your server is, and what technology you use for it. This question has nothing to do with Android, as you'll probably communicate to your server using HTTP or another protocol that would allow it to communicate to your android app (the client) and maybe later on, to different kind of clients (web app, iOS, etc.). So you can use any database technology, Oracle, MySQL, Postgres, whatever. You can even build your server application using Microsoft .NET technology, or anything else. You're not tied to Java / Android (although my personal technology stack of choice would probably be a Jetty HTTP server, Oracle database or MySQL if you want lighter, and Java of course).
On the client side, you may also want some data storage, and in this case it depends on the size and complexity of what you want to store. For simple key-value pairs, use SharedPreferences. For more complex data structures, SQLite is your technology of choice.
I would like to connect to a MySQL Database hosted on the same server with a Tomcat Server from my Android App without using PHP. Is there any way to do this? I found some solutions but all use PHP.
Can I connect directly or do I have to do it through a Web server?
Because you're running on Tomcat I imagine the best way to access the database would be to write a webservice that handles the communication between the app and the server.
The webservice will be written in Java to run on TomCat using JSP.
I'm guessing you're trying to communicate directly with the MySQL database (i.e. run SQL commands on the database directly) but I don't think you can do this (although never tried or looked into it), I have always been under the impression that you need some code on the server to sit inbetween.
It should be common sense, that directly communicating with databases over the web is a "no go" security wise and with mobile devices a pain regarding the connectivity.
Setup a webservice with JSP or Grails (which I find comes with less workload) and deploy it to your tomcat server.
Hence the thought, you already have a Tomcat running, one assumes you have a java web app running. Try adding a webservice to that app or look in the documentation, if there already is one.
You actually cannot do this with Android the main reason is performance it is really expensive to keep a remote connection alive than rather just call Web Services on demand, and it is more portable.
So i recommend you to play around with your favorite language creating services that access to your database and digest the output (XML or JSON) with android.
BTW i also think this have been asked Android MySQL Connectoin and here is a nice tuto about it (but with PHP) it should be fairly easy to do it in Java.