Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New transaction is waiting for open operation sqlite

I'm using this plugin : https://github.com/litehelpers/Cordova-sqlite-storage

I'm getting above issue in my project while doing DB transactions. Actually there so many transactions in my project at same time from js as well as java end.

Below is my code (just one query) :

function createTable(latWS,longWS,empId) {

        window.sqlitePlugin.openDatabase({name: 'test.db', location: 'default'}, function(db) {
        db.transaction(function(tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS test (loc_emp_lat, loc_emp_long, loc_emp_accuracy, loc_emp_local_time)');
        }, function(err) {
            console.log('Open database ERROR: ' + JSON.stringify(err));
        });
      });
        setTimeout(insertIntoLogTable(latWS,longWS,empId),500);
    }

I have checked, it is not going in error message.

I'm using version : cordova-sqlite-storage 1.4.7 "Cordova sqlite storage plugin"

My Cordova Android version is : 4.1.1

like image 952
Anjana Avatar asked Sep 01 '16 05:09

Anjana


1 Answers

I had the same problem with react-native-sqlite-storage (which is based on Cordova-sqlite-storage) on Android.

The createFromLocation parameter was responsible for messing things up. Using only the name parameter is sufficient on both platforms.

This is what I'm using, on both Android and iOS:

SQLite.openDatabase({ name: "dbname.sqlite"});

On Android 7.0, the database will be saved to /data/data/com.mypackage/databases/dbname.sqlite.

like image 144
vmarquet Avatar answered Oct 26 '22 00:10

vmarquet