//https://bdsc.webapps.blackberry.com/html5/apis/Database.html
//Create a namespace to hold our database variable
if (typeof mynamespace === 'undefined') {
mynamespace = {};
}
(function() {
//This method is only called once (the first time the database is created)
function onDBCreate(database) {
//Attach the database because "window.openDatabase" would not have returned it
mynamespace.db = database;
//Create the table in the database
database.transaction(
function(tx) {
tx.executeSql('CREATE TABLE tbl_name (key int unique, name text)', [], function(tx, res) {
alert("Table Created Successfully");
}, function(tx, err) {
alert("ERROR - Table creation failed - code: " + err.code + ", message: " + err.message);
});
});
}
if (window.openDatabase) {
//Will either return the existing database or null and call our creation callback onDBCreate
mynamespace.db = window.openDatabase('awesome', '1.0', 'The most awesome database ever', 5 * 1024 * 1024, onDBCreate);
} else {
alert("This device does not have HTML5 Database support");
}
}());
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.