
I’ve been deeply fascinated with the great API, Google Gears, introduced by Google recently. I’ve taken the very first step, that was quickly to make use of the Local Database API to build my very first Google Gears app. This is mainly due to my background is more on database apps and Java, that’s why I chose the local DB API to start with. It’s really amazing that what Google has done, which allows JavaScript applications to make use of relational database engine to store data and SQL statements to manipulate data locally.
Pretty close to Java syntax and DB security is well taken care.
The very first app that I built is hosted here (posted on AjaxApp.com earlier on), which is a very simple app that consists of three simple parts. These three parts are a form for adding simple record that consists of only a name and an email field, a record listing section and also the record searching section, which you can search using SQL wildcards such as %, * etc. These three parts are making use of the local database API, one of the three components introduced by Google Gears to store data locally i.e storing data at the user’s local hard disk using SQLite database engine. I’ve been a database and Java programmer for quite some time. I found programming using local database API of Google Gears is definitely easy to pick up. Especially its syntax and handling is very close to what Java’s java.sql.PreparedStatement offers, which the SQL injection is well-taken care of.
Usefulness of Local Database API for developers
Of course, the intention behind the entire Google Gears not only for the local database API for storing data locally. The local database API is useful for certain applications which allow data to go offline and sync back to the server online when there is Internet/network connection or necessary. And it provides the easy way for developers to store data locally instead of using other dirty methods such as cookies handling etc. Of course, it provides much easier and robust way to store and retrieve data. And no doubt, another great is the speed of the app if data can be stored locally first, without needing the long wait of user. (Data sychronization with the online server can be quietly done using async JavaScript that makes use of the worker pool)
Google Gears offers application to go offline and great worker pool for threads
Google Gears with its three great APIs, the LocalServer, the local Database and WorkerPool together are simply best for building applications that provide an option for the application to go offline when there is no network or Internet connection. And it also allows the synchronization of data back to the server while there is network or Internet connection. This can be done asynchronously, such as periodically detecting of network connection and sending data to and flo to the online server, using the worker pool threaded processes, without affecting any other actions that the user is focus on. (Please note that the synchronization part will consist of AJAX to communicate with online web services written in server-side technology such as JSP, Java Servlet, PHP, CGI, Ruby, ASP, ASP.net, Perl etc)
What apps are suitable to have offline option?
As pointed out by Google Gears team, not every app is suitable to have an offline option. For example, an app that needs the life data every second from the online server, such as an stock pricing ticker, a chat application are not suitable to have an offline option. In real life, what I could think of for the time being, those apps needing offline option are such as follows:
1. An enterprise web portal application that offers the staff to query the inventory and issue sales order or invoices, is suitable to provide an offline option. Which it can allow the frequently travelling sales personnel to take the app offline and have a local copy on his laptop hard disk and sync back to the server while he/she manages to get network or Internet connection.
2. General applications such as online word processing, email, calendaring applications etc. The offline option would be useful for frequent travellers, which you can be productive too even though you don’t get network and Internet connection. And the data will be automatically synchronized to server when the next time the app is launched again with a network or Internet connection detected. Of course, there are lots more, just need to twist you brain.
The next thing I wanna try on Google Gears
Of course there are plenty of stuff need to be explored and learned before I can use it to build serious apps. Such as the security, the ability for the local SQLite to store blob type data, the ability of it to handle file upload. I’d continue to enhance my first Google Gears app, to make it to have the option for taking the page offline by making use of the LocalServer API and also the intermediate data layer that handles storing data locally and synchronization of data back to the server database. And some apps that I wanna build that are currently in my wish list by using Google Gears are an online PIS (Patient Information System), a small online inventory or an web-based email client that provides offline option etc. I’m gonna have one section on TechChee to present them here once I’ve got each running. And I’ve just dedicated a new category for the Google Gears here, for future info update, tips and development of Google Gears. Thanks for bearing with me for this lengthy post. Hope it doesn’t bother you too much and the next few posts shall continue on gadgetry.
Google Gears,Google,Google API,JavaScript,AJAX,API,Web Programming
Technorati Tags: Google Gears, Google, Google API, JavaScript, AJAX, API, Web Programming








October 30th, 2007 at 9:07 pm
[...] WebKit has got some cool asynchronous API that follows one of the specs of the HTML 5 i.e. allows you write JavaScript code to store data, using SQL statements that you’ve been familiar with, so data can be stored on the client’s computer. This should work more or less similar to one of the features that the Google Gears offer – the Local Database API. This would be useful for those applications that wanna store more information on the client sides, a much better way and easier to manipulate by using SQL statements instead of nasty cookies. More info and code after the jump! [...]
October 22nd, 2008 at 5:29 pm
[...] Gears – the browser’s plugin which allows a web app to work offline and store data offline, has just been released with the new Geolocation API, allows location-enabled web sites to securely [...]
March 18th, 2009 at 5:49 am
can i pals… can any one send the code for working in offline and send the data to database while connecting Network…
jus i need for simple insert and update data can any one help….