views:

52

answers:

1

I'm trying to use Storage mechanism in mozilla platform (in thundebird 3.0).

The following code is used after each test to erase the table present in the database:

function tearDown()
{
  let database = new Database();

  let req1 = "SELECT name FROM sqlite_master WHERE type='table'";
  let statement = database.connection.createStatement(req1);
  let tables = [];
  while(statement.executeStep()) {
    tables.push(statement.row.name);
  }
  statement.reset();
  for(table in tables) {
    let req2 = "DROP TABLE " + tables[table];
    database.connection.executeSimpleSQL(req2);
  }
}

But I've an error during executeSimpleSQL of req2 (NS_ERROR_FILE_IS_LOCKED), It seems that sqlite doesn't release the lock from the first statement. I've tried reset(), finalize() but nothing works. How can I properly release the lock of the first statement ?

+1  A: 

Answering myself: I forgot to release a previous statement in previous code of my application.

Final story: when you use

statement.executeStep()

Check:

  • be sure that the last call of this statement return false
  • or never forgot to release it:

    statement.reset();

Kartoch