ApacheCon demo - Web Browser Client Offline Storage with Java DB / Apache Derby

What I demo'ed at Apache during Tim Bray's keynotes was one particular use case of embedded Apache Derby (100% pure Java RDBMS) running within a web browser such as Mozilla Firefox...This allowed me to persist data automatically as HTML FORM fields got changed (at the field level or not) - It autosaved data entries locally without being paranoid about loosing my data in case of a browser crash or bad manipulation (fat fingers anyone?)...The store service can be called at anytime really from your client script...

Various database systems excel at different types of needs...My intent here was to use Apache Derby as the repository for an application managing some user's personal data (i.e. personal/private/financial taxes info). This is very different than managing browser's data/metadata (i.e. bookmarks, history, cache, etc) at the low-level and where indeed I would need a closer integration of the RDBMS with the browser engine...The demo highlighted how a web application could be enhanced (fast, embedded and secure local SQL storage) across web browsers, not just how it could enhance a particular web browser (i.e. Firefox).

As this particular demo manages personal and financial data, it is very likely that a production application would want to encrypt the data stored on the client storage - This is a possible and very likely an application requirement for this type of webapps. Derby supports strong encryption at the database level as well as strong authentication at the Derby engine or/and database level. Hence, I can have my local derby database(s) be secure, portable and platform independent without having to worry if I loose my usb drive or stick and my DB is on it...Derby also has some ACL-light support for embedded type of apps but Ansi SQL Grant & Revoke is being implemented as we speak - this is independent of the OS FS file permission scheme and is portable across OS's.

The demo I shown is one particular browser database integration scheme/topology - I did not have to \*natively\* integrate with the browser engine at all for this application. It was all driven from the application scripting logic interacting directly with a ClientStoreService object - This last one is implemented in Java and acts as a controller to the local client storage (Derby). It is seen as an object from Javascript (LiveConnect technology) which allows me to access some client storage service to issue queries and get data returned in XML, parse/process it with the native scripting engine XML Dom parser. The ClientStore Service can process requests asynchronously or not - I have another implementation where I added some HTTP request handling capability to Derby but this is NOT part of Apache Derby (yet) - this allows me to send a (Local) AJAX request (LAJAX) to Derby directly and get data returned as XML. The scripting engine does NOT have to be Javascript for the (L)AJAX mode...

For the Java engine I used Sun's JRE (browser Java plugin) which is a one-click install and is portable across and widely known web browsers.

Requirements for this Webapp demo were:
- A fast, embeddable, portable and secure (authentication/authorization/encryption) local client storage engine
- Portable across most widely known web browsers (at least 2 of them)
- Support for scripting standard asynchronous requests (Ajax mode) to the embedded client data store
- Various deployment options for the web application and database engine
- Support for direct access via a client scripting engine (non-Ajax mode, ala LiveConnect)

The deployment options for the ClientStorage engine and service would be:
- Direct HTTP download and archival of JARs,
- Direct copy of files,
- Firefox extension (w/ a dependence on the J2SE runtime environment Firefox plugin)
- Web shipping of already pre-populated databases, then made available locally to the web browser.

You can read all the details about this demo and get the source code at:

Thanks for reading...



I would love to hear how the demo was achived, it is a very interesting idea. I was thinking about doing a project like this using JNLP and the HSQLDB database engine so offline use would be possible, and did not consider the use of Apache Derby or AJAX. I figured that the limitations of html+javascript would be too great, and I had not really heard about the Derby project. Having a standard way to extend web applications in this manner would open new doors. Thanks to you and Sun for sharing.

Posted by CharlieK on December 19, 2005 at 12:59 PM PST #

I'd love to see details for the code, setup, etc.!

Posted by Dale Asberry on December 20, 2005 at 12:29 AM PST #

Details about the demo have been posted at:

Posted by Francois Orsini on November 28, 2006 at 11:47 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed



« February 2016