Multiple Web SQL created?

Multiple Web SQL created?

This might not be a problem at all but I just need to check.

I am using a Web SQL db to store some info from a external xml  that I use in the web-app. Everytime someone goes to index.html it does a sessionStorage check to see if we have already loaded the stuff from the xml. If not it fetches the latest data and re-populates the db. So far no problem.

However - on index.html I also have a second page with the id view which I link to (<li><a href="#view" onclick="viewResult();">View result</a></li>). This page creates a list from data in the DB using this javascript:

  1. <script>
  2. function viewResult()  { 
  3. $('#listan').empty();

  4. var db = openDatabase('LaurDB', '1.0', 'LaurDB', 2 * 1024 * 1024);
  5. db.transaction(function (tx) {
  6. tx.executeSql('SELECT * FROM laureates', [], function (tx, results) {
  7.  var len = results.rows.length, i;
  8.  var html_sub_string='<li data-role="list-divider">Results</li>';
  9.  for (i = 0; i < len; i++) {
  10. html_sub_string = html_sub_string + '<li>' + results.rows.item(i).category + ' ' + results.rows.item(i).year + '<br>' + results.rows.item(i).name + '</li>';
  11.  }  
  12.  
  13.  //$('<li data-role="list-divider">Results</li>' +  html_sub_string + ' <li data-role="list-divider">End Results</li>').appendTo('#listan'); 
  14.  var html_string = html_sub_string + '<li data-role="list-divider">End Results</li>';
  15.  
  16.  
  17.  $("#listan").html(html_string);
  18.  $("#listan").listview("refresh");
  19.  
  20. });
  21. }); 
  22. }
  23. </script>

This also works fine. I can move to the page and back. 

However, when I check with Chrome Developer Tools/Resources/Databases to see the database I notice that everytime I move to the "view-page it adds another DB with the same name. So if I move back and forth a few times I can end up with:

LaurDB
LaurDB
LaurDB

all with the same info in them. If I refresh the index.html I only see one DB again. Is this a bug in Chrome or am I actually creating a lot of duplicate DB's for the app that will take up space? 


/Björn