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.
Related
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.
Im workings on java project.its a desktop application (financial application).
I want to when user in offline save all data in embedded database (H2 database) and when user come to online or click on some button save all the new data on Standalone database(My SQL server) server.
Right now i kindda lost with this scenario.
Can some one describe how this should be done or is this possible.
Based on Assumption as your question seem to pointing below requirement,
you have local H2 database
mysql may be on other network.
If you save some data on application then goes to h2 database
one you connected to internet the data should go to mysql database which is on differnet host from h2 local database where application is running.
Solution :
you need to add replication tools which replicate data from one database to another seemlessly.
Refer One of the nice tool : https://www.symmetricds.org/
Let me know if you have any other requirement. Also please provide enough details when raising the questions. Thanks.
Replicating data from H2 DB to Mysql DB using a replicator tool is one way.
Other way to achieve the same is rather than creating a heavy in-memory DB instance on client machine is you can write the same data in file on client machine at some location and write a scheduler program which will check the heart beat of socket and if ping to your server is successful you can read file and upload the data to your actual DB server. Also Writing your own scheduler and data uploader will give you more control.
Other issue with any replicator tool is data type compatibility.
Still if you want to go ahead with any replication tool- you can have a look at Tungsten Replicator - https://docs.continuent.com/tungsten-replicator-4.0/deployment-oracle-fromoracle.html
When I want to create an SQLite external database for android application, do I have to have a server with database that is always running?
Yes, since it will be on a server. If the server isn't running, then your application won't be able to get any data from the database.
There's a very important distinction that we're missing here - what it means to have a remote database.
SQLite is a flat-file embedded database engine. You don't have a separate process running SQLite in the background like you would one for MySQL or PostgreSQL or Oracle, nor would you really want to - SQLite as a database is pretty limited in what it can do.
If you say that you're going to have a remote SQLite database, then that implies that you have some server somewhere that writes to and reads from this flat-file database. If you can finagle that somehow, and make it secure, then more power to you - and yes, you could have this accessible remotely for your intents and purposes. Trust me though, you wouldn't want to.
What you're likely looking for is a way to remotely run MySQL or PostgreSQL instead, as these are proper database management systems (DBMS) which will be able to both service remote connections and give you a more expanded set of the SQL language.
Ultimately though, the database server must be running at all times. You wouldn't be able to connect to the database if it's down, and you don't know the lifespan of the app (or when it's going to be accessed, etc).
i got the below information from SQLite home page
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
Based on the above statement you don't any server. I hope this information is useful to you.
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.
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