Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync)
- I created a small JS lib named WebSqlSync to synchronize a local WebSql DB with a server (client <-> server). Very easy to use and to integrate in your code :
https://github.com/orbitaloop/WebSqlSync
- The open source project QuickConnect contains a JS library to synchronize the local HTML5 SQLite DB to a server DB (MySQL or other) :
http://quickconnect.pbworks.com/Using-Enterprise-Synchronization
To use this lib, you need to use the DataAccessObject of the framework to access your DB. It works by storing all the SQL request applied to the DB (except select of course) , and sending them to the server. It's great to manage deletion, but it's a little heavy if you have a lot of updates, and the server need to use the same SQL language...
- Another project from QuickConnect is a native SQLite synch (in Objective C for iOS or Mac OS and in Java for Android) :
http://www.quickconnectfamily.org/qcdbsync/
(I think it store also the history of all the SQL requests)
- And i just found another promising JS library : persistenceJS
https://github.com/zefhemel/persistencejs
"persistence.js is an asynchronous Javascript object-relational mapper library. You can use it in the browser, as well on the server (and you can share data models between them)."
They have a DB synch module: DOC of persistence.synch.js
(works with HTML5 DB SQLite or Google Gears on the client, and MySQL on the server)
- And there is also Impel.inTouch. It looks very easy to use (with php files included), but you must use the Mootools framework in the client side :
http://impel.simulacre.org/api/Impel.inTouch
- Sencha has also a synchronisation service: Sencha.io. Looks great, but it's dependent of the Sencha Touch framework:
http://www.sencha.com/products/io/
How to synchronize HTML5 local/webStorage and server-side storage?
Firebase offers this functionality as a service.
Another alternative is Parse.
WebSQL and MySQL synchronize
The best way to automatically synchronize a local WebSql database (SQLite of the browser) with a server should be this repo WebSqlSync.
Features :
- 2 way sync : client <-> server
- Incremental synchronization (send only the necessary data)
- Works offline. All data changes are tracked and synchronized with the
server once the connection returns - Support for replicating changes to multiple devices
- Support for Basic Authentication
- works with any JS web app or phonegap app (iOS, Android, etc.),
without changing your code - only 4kb gziped (and no dependencies)
- MIT licence
Installing :
Just copy the src/webSqlSync.js file in your project and include it in your html :
<script src="lib/webSqlSync.js" type="application/x-javascript" charset="utf-8"></script>
Can we set values to localStorage (HTML5) from bean class.?
No it is not possible. Local storage is a client side feature. So unless you are using GWT (there is a Storage
class) there is no way to set it from Java.
Please note however that there are many tools/services out there that allow you to synchronize your back-end store with HTML5 storage such as Firebase.
You can find additional information on that matter here: Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync) and here: How to synchronize HTML5 local/webStorage and server-side storage?
Related Topics
Html/Css Hexagon With Image Inside
Media Queries For Different Zoom Levels of Browser
What Are the Integrity and Crossorigin Attributes
How to Turn Off Word Wrapping in Html
What Does It Mean in HTML 5 When an Attribute Is a Boolean Attribute
How to *Really* Justify a Horizontal Menu in Html+Css
Chrome Download Attribute Not Working
Why Does the Checkbox Stay Checked When Reloading the Page
Canvas Drawings, Like Lines, Are Blurry
Do We Still Need Forward Slashes When Closing Void Elements in Html5
Change Cursor Type on Input Type="File"
Animate/Shrink Navbar on Scroll Using Bootstrap
Why Is There a Vertical Scroll Bar If Parent and Child Have the Same Height
Dom Mutation Events Replacement