Hello every one I am new with servers things. I want to develop program that get data from the database on the server and it's my first time I don't have any idea of this thing.
Let say like Login & Logout:
how can i make a virtual server for testing on my PC
how can i connect the emulator with this virtual server
how can i request the data from thee database
Do I need software like Xamp or Wamp? If yes how can I use it?
I found so many examples about the json and webserver but I don't know how to make virtual server and connect the emulator to it.
as I understand this problem you need two separate pieces of software. You will need 1) server. To begin with you can install XAMP and WAMP to get Apache running. There are millions of tutorials on how to set up an Apache web server online, and to begin with you could just return a string or a simple data structure (e.g. JSON or XML). As you want to do more complex things you can learn more, but in the beginning think "easy does it". From your text I anticipate that you just want to test as a proof of concept.
- What OS do you run BTW?
Another solution is to rent some space on a server accessible from the Internet. Then you could test your server-side regardless of where you are located.
Second you would need to create a program for the android. There are several guides, but have a look here: http://developer.android.com/training/basics/network-ops/index.html. If you choose to make your data available through the HTTP protocol there are very boilerplate-like procedures for how to download and parse the data.
If you are hosting the server-side on your local computer you would need to use local addressing, but if you choose to put it online you could acquire the data from everywhere as long as you have an internet connection.
Good luck!
Related
What I'm trying to do is connect a Java Android app with a FireBird database that is stored in an enterprise server.
I realised i need to use some kind of webserver to avoid connecting to the database directly.
In other words, something like this:
Android app -> WebServer -> Database
My problem is that although there are plenty of examples none of them let me do it.
Where can I find a full example of making the webserver, retrieve data (images, datasets, etc.) and how to connect my clients to it.
And obviously if there is a better way to do what I need that I'm not aware of.
Thanks in advance.
I've looked around trying to find an answer to this question, but have so far been unsuccessful. I have a current version of an Android mobile application that stores items in the local database, and I'm trying to hook it up to a 'cloud' database (not sure if this is the right term) so that other people that download the app will be able to view and post things to the database.
I have an ec2 service set up, with my LAMP stack installed. I have the database set up on this server ready to go. How do I go about hooking up the Android application so that it can communicate (insert/view/delete items) with the database? I am a new developer so any help/insight/guidance you have is much appreciated!
You haven't mentioned the type of database you have setup on cloud.
I am assuming it to be some kind of relational database (e.g. MySQL).
You can use standard JDBC connection from a regular java code but it is not yet possible (supported) to do it directly from Android code.
I faced a similar issue, what I did was this:
Create a Servlet and deployed it on GAE (Google App Engine).
Make an HTTP request from your android application code to this Servlet (SELECT/UPDATE/DELETE).
Initiate a JDBC connection to your database (on EC2) from that Servlet.
Shoot the SQL statement to the database.
Get the result and send the response back from servlet to your android code.
There may be other better solutions but I could not find any and tried this on my own, it worked like a charm, multiple times.
After writing the previous answer, I kept on thinking of alternate solution.
FYI: This may or may NOT work !
Instead of hosting your servlet on GAE, you can host it on the same EC2 instance as your database, using tomcat or any other package.
This way your android code would communicate directly with the instance that has servlet and database deployed together.
In the servlet, you can shoot SQL queries internally and send the results back to android code.
How to host a servlet in Tomcat 7
Adding new security group and linking it with my instance..worked for me
I am trying to develop a real-time Android application where all contents are stored in server. So, they are available whenever a connection to Internet is available. Also, the application provides communication between users and conversations are stored in the server as well. Nothing is locally stored.
However, I am still cannot decide which database type I can use. I intended to use SQLite but I am not sure if I can really use it or not.
Could you please guide me to the proper database type to my application.
Appreciate your time and efforts.
As its upto you which database you use.
you may Install Lamp (For Linux) or WAMP(for window) . This is a nice database tool and very easy to handle and easy linked with PHP for various database function
I recently developed something similar to what you are talking about and here is what I would suggest you to go for.
Use SQL server to manage the data on your desktop and create a web-service in .Net on Visual Studio.
(Note that as others have already mentioned, it really does not matter what is the database you are using in your server end, because eventually the data is going to come to the Android application from the server in form of either xml or json in the web-service., regardless of what database you are using. So it is totally your wish which database you want to use.)
Then connect to the web-service in your application and set/get data from the remote Database, using SOAP.
Link on how to make a web-service in .NET (does not include the implementation in Android).
Links on how to connect your service with Android : this, this and this.
Friends
Any one can tell me ,, what Strategics or steps to connect my android app to SQL server ??
i want to developer android app , this app connected to Sql server direct , and whats best choices to do that ???
thanks for help
You could use a webservice to provide service orientated architecture (SOA).
For example you may have a database with a PHP/Java/.Net application connected to it. When a mobile device makes a web request to this application, it returns data to the device.
The data returned could be in a choice of formats such as json or xml. Personally I prefer json if mobile devices are involved as the footprint from json is smaller than xml due to its characteristics. However that said, should you need meta data in the response then xml maybe more useful.
There are many tutorials on this and libraries to help deserialise responses (GSON from google is good when Json is involved), therefore I am not going to reinvent the wheel when others before me have explained this before and probably better.
Finally; the use of a webservice allows for multiple platforms to communicate with your database (and other services you offer) and allows for any 'heavylifting' to be done on a server rather than a mobile device.
From your comments to Graham Smith's answer, I understand you prefer to connect to SQL Server directly, without an explicit webservice or other communication layer in between.
You have to understand: android devices are usually mobile, so an indirect connection that doesn't require the android device to be in the same network as the SQL Server (including the security horrors that brings along in an enterprise environment) is usually preferred.
Back to the actual question: you can us JDBC to access SQL Server from Android. Either use Microsoft's own JDBC Driver for SQL Server, or use the Open Source jTDS . The latter seemingly solves some connection problems some peole seem to be having with the Microsoft driver.
Below I explained what I need and in the answer I would like to get information what technology, what kind of protocols, services etc should I use.
Also I know that there is a massive amount of information on the internet, but because there are so many choices I'm unable to make a decision. Here's what I want to have:
Android application which will sent and receive information from the internet/server
Of course server, which will do some rudimentary computation with the obtained information, then store it and at the end send it back to the client application
I have to admit that the subjects of networking, socketing, protocols, ciphering etc are the ones I've always run away from. Therefore advices such as what domains, databases etc utilize are highly welcome
Update: After a bit of a research I've implemented mechanism based on information from this site [1]. I already have a working MySql database with several tables inside. Also I've added php scripts to my Apache webspace and implemented all that's necessary within my Android app.
Now, as I understand communication between php's scripts and MySql database is safe (I've hardcoded the usr/pass within scripts). Therefore the only thing that has left to be done to secure the connection between my Android application and php scripts (I want to prevent the situation when everybody has an access to my php scripts). So my question should be pretty straightforward now, how can it be achieved?
[1] http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/
I think a simple TCP/IP connection via Sockets will do just fine for your purposes.
The lesson (with more information and some examples) from the Java-Docs can be found here.
The basic workflow is as follows:
Your Android-App opens a Socket-connection to your server on a
given port where a server-application listens.
The Android-App sends it's data (whatever that might be) to the
Server.
The Server reads the send data,
processes it,
stores it...
...then it sends back some response (maybe the computed values) to your
Android-App.
Your app can then figure out if everything went okay and use the
given data.
Answering my second question, all the php scripts has been put into directory with the password on my Apache server. To be able to trigger them I need to give this password which is hardcoded in my application. All the connection is done through HTTPS. Now everything works as planned!