Embedding a Database in the Browser

OSCON 2006 workshop report

Embedding a Database in the Browser

David Van Couvering
Database Technology GroupSun Microsystems, Inc.

Why would you want to embed a database in the browser? Well, for one, the mobile user isn’t always connected. Keeping personal data off the server (and keep it in your control). And then there’s the fast local web cache — for more performance, store the data on the client’s browser.

What you need to make this work:

cross-browser support and feature-rich language (Java), embeddable, small footprint, standards-compliant, secure, robust = automatic crash recovery (people are always closing their browser).

So why use a database? Why not a cookie or other text?
standard, portable API
ACID semantics, even if there’s multiple threads
Flexible data model
Powerful query capabilities
Works with lots of existing tools, using existing skills. nothing new to learn.

Apache Derby fits into this — 100% Java Open Source relational DB — http://db.apache.org/derby — embeddable, small footprint, standards-compliant, secure, automatic crash recovery.

Not quite AJAX, more like LJAX — local javascript and xml, not asynchronous because you’re not synching to the server. You could also use this technology to embed a web server in a browser.

He called these embedded things “applets” which makes me cringe….ie, “let’s use servlets offline, using applets!” Didn’t we already try this?

create the db, put the directory into the application’s JAR file, and then you copy the JAR to the local filesystem — for which you need to sign the JAR and wrap it within PrivilegedAction.

(he talked about security — if someone steals your laptop, won’t they access the info on your browser?)

It’s basically a geek hack. I’d wanted it to basically be “how to supercharge cookies” and use features already in most browsers to enable an embedded database, therefore making apps much faster. Sadly, not the case. A neat technology nonetheless.

Comments are closed.