Skip to Content
Author's profile photo Marco Eidinger

SAP Cordova Plugin for Sybase UltraLite consumption as easy as Web SQL

I’d like to share my latest contribution for SAP Cloud for Customer which is part of the CRM cloud product offering by SAP. Soon new hybrid mobile applications will be published to offer a responsive HTML5 UI and enhanced offline capabilities. For the latter aspect I implemented a Cordova plugin to leverage UltraLite as device storage medium.

It’s an SAP internal plugin but there are discussions to bring it to the Cordova community. Let me know your feedback.




Prototype for a Cordova plugin which uses UltraLite as database so that web applications running with Cordova can store information inside an relational database on the device.

What’s UltraLite

UltraLite is a relational database designed for small-footprint mobile devices, such as smartphones, PDAs, tablets and laptops. It’s part of SQL Anywhere from Sybase.

Plugin Javascript API

The plugin emulates the API for the Web SQL database as best as possible + enhancements.

Database handling

The openDatabase() function is enhanced to provide an encryption key for which the database will be encrypted with the AES algorithm. Encryption is optional.

var openArgs = {name: "myDbName", encryptionKey:"myKey"};
var db = window.ultraLitePlugin.openDatabase(openArgs);

The openDatabase() function is also enhanced with two optional arguments

var openArgs = {name: "myDbName", encryptionKey:"myKey"};
var fnSuccessCallback = function() {
    console.log("Database opened / created");
};var fnErrorCallback = function(sErrorMessage) {
    console.log("Database cannot be opened because " + sErrorMessage);
var db = window.ultraLitePlugin.openDatabase(openArgs, fnSuccessCallback, fnErrorCallback);

It’s possible to change the encryption key but you have to call openDatabase() first to get the db object and you have to ensure that no SQL statements are still running.

 console.log("Yuuh, db key changed successfully");
      console.log("ERROR: " + error);

You can close the database connection or even delete the database. Here an example how to delete


Transaction handling

One or more SQL statements can be executed in a transaction. The transaction will call COMMIT implictly in case no error occured. Otherwise a ROLLBACK will be executed. You can register callbacks to identify if the transaction was successful or not. The result set for a SELECT statement, returns the alias or correlation name and exclude any table names that were specified.

Same behavior as Web SQL.

Logging / Tracing

An additional enhancement is to offer logging/tracing. Tracing can be enabled via enableTracing(). Logging/Tracing is deactivated per default.

It’s possible to specify log level (ERROR = 0, WARNING = 1, INFO = 2, DEBUG = 3). Default log level is ERROR.

It’s possible to specify a callback function to be called for log statements. If not specified then the console will be used for logging.

var fnLogCallback = function(iLevel, sText, sLocation) {
    // do something with the information
window.ultraLitePlugin.enableTracing(true, 3, fnLogCallback); // DEBUG

Supported platforms

  • iOS
  • Android

Additional info

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.