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.
Related
I'm studying android and I have a question. How to transfer data between app and client ? which DBMS I can use ? and how to make my laptop become server ? all of this I just want to practice. Thanks for all advice !
you need a server program which service requests via web services. So this is the server program which has access to DB and choosing DBMS does not depends on android app. when your server program reads data from DB, it'll send them to android app in JSON or XML format (most common formats).
you can setup a local network in your laptop and connect you cell phone to that. but for testing purpose you can use emulator in your laptop.
I want to build a website, where the data will be saved in a data base, logical in a sql database. Also, I want to build an android app, which will take the data from the above (sql) data base. How can I achieve it? I mean how can I manage the communication between the website and the android app. In past, I have create website with php and sql and also I have build android apps, but now I want to achieve the communication between them. Can I use parse platform?
FYI, without any server communication you can't use the website database in android application.
If you want to manage the communication between the website and the android app means you need a centralized server which having the data of your web/mobile applications. So, after that by using the web service methods (REST/SOAP) you can achieve the communication between them.
yeah unfortunately chrome won't let webapps use local storage on android. what you can do is create a local server (using org.apache.http package for example), let it run as a background android service, then have the website make requests to that url. Its considered hacky, but it would work. You can post whatever data you wanted the website to know about , and then get it from the website.
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.
First time working with android. I'm look for a way that an android app can connect to a remote database. However, this is on a closed network with no internet connection. Just the phone and the server.
I wanted to know the best way to connect, if its through JDBC or if its possible through android's SQLite class, or something else?
The phone is running android 2.1 and the database is a MySQL database.
Any guidance is much appreciated.
Thanks,
As long as the device is connected to the network, which would have to be via wifi, you can access a MySQL database hosted somewhere on the network just like you normally would.
My advice would be to set up a RESTful web service on the server which hosts the database. Your Android client application can communicate with this web service using HTTP requests and the web service can talk directly to the database. I'd say this is the most common approach for working with remote databases when it comes to Android.
Android Client <==> RESTful Web Service <==> MySQL Database
Android has a couple different ways to communicate with a web service: HttpClient and HttpUrlConnection. I think the latter is generally the most preferred way nowadays.
As far as I know, JDBC is unsupported for Android, and the Android SQLite API is strictly for using an embedded SQLite database.
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.