How to synchronize Data with a ServerDatabase? - java

My application should be syncronized with a ServerDB to collect some Data all users input.
How to do that in android? Through xml and evaluating these through self writen queries? Or is there a more elegant solution?

This is a good thread for you How to communicate with server's database from android phone?
Basically, you should not use a JDBC / SQL connection directly as it doesn't suit mobile needs. But you build a web service your database on the server and communicate through the service to update your database and get refreshed data from it.

Take a look at the SampleSyncAdapter sample app.
Android apps can sync their content provider with a web-based database using the SyncAdapter class, which handles many of the details of scheduling and running synchronization. Sync adapters will try to avoid conflicting with each other, they won't run when the network is unavailable, and the user can configure them from the Accounts settings.
Even if your app is the only one using the mobile database, you should use a content provider, to allow the system to manage interaction between the db and the web.

Have a look in :
http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php

Related

How can I connect my Android Application to a database (and what should I be using)

So I am planning on creating a side project which is similar to Twitter, where the basic functions are to create accounts and store data such as username/password. And for users to create statuses and allow them to be visible on a 'news feed' so it should store the status in the database as well.
The front-end will be developed and designed for Android using Java, but how will I connect it to the database and what should I be using?
I recommend you to use firebase as a back-end database. It is very easy to learn and configure. For more info visit this link: Firebase

sybase updating gigaspace cache on insert/update/delete

I am new to database and i am working on an application which has a gigaspace based cache and the backend data is a sybase database.
Unfortunately there are a lot of places from where the DB gets updated via stored procs. Hence i would like to have a way via which i can get notifications whenever my DB is updated.
After doing some research i found that sybase does has the ability to send out events to Tibco EMS but unfortunately it requires separate license.
Is there any other reliable way i can get table update notifications without using a messaging system like may be some kind of rest ?
You can send a message to a UDP port using syb_sendmsg(); this requires some configuration settings but no license. Note that UDP is not as reliable as TCP.
If you don't want to use any more licensed options you could make a trigger on the table and put code in the trigger that would send data to JMS.
Or it can call some custom Java class (Java in database) that could do virtually anything.
Another options i to use XP server and call some external program that would populate the cache or JMS queue.

Android Client-Server App & Web Services

I have a website that I'm wanting to create a Java application for, and while I don't have any experience creating android applications I have a decent amount of Java experience and feel like I should be able to complete this task over some time. I'll be making use of the Java.IO package for client-side networking (On the application) and hosting a server using Java. This server application will have access to all of the same databases as the website through JDBC. (I'll be hosting it all on the same server.)
My question is how to go about handling connections on the android platform, currently I verify a dynamically generated salt with the database salt on every page refresh to prevent session theft. I also make sure that the encrypted password and the user-name stored in the session match.
I could theoretically just create a standard server application, using NIO and avoding the whole thread-per-client scenario. The problem is that my website has quite a bit of traffic, and I know the application will too. So I'm running into issues on how to handle it.
If I use a keep-alive TCP connection and store the users basic information in a class data structure (Psuedo example):
class User {
int id;
}
Considering all information will be polled from a database and everything is relative to the id of an account, there's no reason to store any excess data into the User class, correct? Just a quick simple lookup tied to the connection to only get data relavent to yourself.
Should I avoid the use of TCP networking for this? What do you guys think.
On the server side, create REST web services that invoke CRUD operations on the server database, and return the responses to the client as a JSONObject or JSONArray. Android has internal support for JSON parsing, and you can use the Volley library to call the web services. Volley is a pretty abstract, high-level HTTP library that makes it very easy to make REST web service calls. TCP connections are quite low-level and are not generally used in client-server Android apps. See the Transmitting Network Data tutorial for more on this.

How do I update data to all application java of shared database

I am creating a web application. Same application will run from different machine, but
they will use common database. When application starts it will get all data from database.
But when I update data from one application, how other running application will know that data
has been updated, I want when I update database form any application, other running
application will get notification immediately, and they should update their data.
One possible solution is I can take all applications URL in a list, then after updating value
I will send request to all application, but how to do this using send Redirect. Is it correct way ? or is their any other easiest way to do this. Please help me.
Is it a requirement that data is loaded once on startup? If it's not than you can just read directly from the database with a low cache invalidation time.
In case your apps need to be synchronized "almost immediately" I would do it like this:
You can set up a messaging server which would create a JMS topic. All of the clients will listen to messages from that topic. When one of the apps update something in the DB it will send a message to the topic. The rest of the apps will get the message and update.

Synchronizing the sqlite database on Android to a Sybase database on server

I'm currently developing a Field-Service application that stores data in the local sqlite database on an android device. At some point, usually after completing the data collection rounds, the local sqlite db is to be synchronized to a remote sybase db on the server.
Any suggestions as to how this could be achieved or engineered as a solution? Or even better, are there alternatives to synchronizing data in such an application?
There are two general solutions that come to mind:
You could have the device send the data to your server in some sort of text format (json, xml, etc) and implement a web service that collects the data. However, both the device and web service will need to understand the protocol.
You could also have the device send the raw database file to a web service and have it open the database, read the file (via SQL) and copy out the necessary bits. However, this couples your device and server to the database schema, but might be less work to actually send the data.
Either way, you'll need some sort of web service to listen for the data that the device wants to send back. The only sticky part is which mechanism you choose.

Categories

Resources