26

I have Cordova application which is version 2.2.0. Now I want to upgrade, I have done upgrade part, after upgrading, application images are not display, it came blank screen. even splash screen also not came. Here is my code

Now I reached to some level. What I have simulated the application, is about SQLitePlugin issue. When Open database say db.cordova is not define

How database installation - copy database from db folder to android installation location. That worked fine.

This is my database:

    var DB              = new Object();
DB.isDBSupported    = false;
DB.isDBCreated      = false;
DB.vocabDB          = null;
DB.tables           = ['userResponses', 'wordGroups', 'words', 'wordMapping', 'checkExists', 'patch_version']
DB.createdTables    = 0;
DB.setupCallback    = null;
DB.curQP            = null;
DB.accountStatus    = false;
DB.sfx              = true;
DB.showWarnings     = true;
DB.firstLaunch      = false;

DB.initDB = function(callback) {
    this.setupCallback = callback || function(){/*console.log("null function called")*/};
    this.openDB();
    var db = this;
    if(!isPhoneGap()) {
        _.delay(this.checkDB.bind(this), 500);
    }
}

DB.checkDB = function() {
    var db = this;
    this.vocabDB.transaction(
        function (t) {
            t.executeSql('DROP TABLE checkExists', [], db.setupDBResultHandler.bind(db), db.setupDBErrorHandler.bind(db, ">>delete exists"))
        }
    )
}

DB.openDB = function() {

    try {
        if (!window.openDatabase) {
            alert('Cannot open database!');
        } else {
            var shortName = 'sns2';
            var version = '1.0';
            var displayName = 'sns2';
            var maxSize = (isAndroid()) ? 5242880 : 1000000;

            if(!isPhoneGap()) {
                this.vocabDB = window.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            } else if(isAndroid()) {
                utils.log("ANDROID DATABASE .. ");
                this.vocabDB = window.sqlitePlugin.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            } else if(isIOS()) {
                utils.log("iOS DATABASE .. ");
                this.vocabDB = window.sqlitePlugin.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            }
            this.DBSupported = true;
            if(isPhoneGap()) {
                this.setupCallback();
            }

        }
    } catch(e) {
        alert("Unable to open db." + e.message);
        return;
    }
}

Service.js

function getGroupCategory(handler) {
    console.log("selecting wordGroups");
    DB.vocabDB
    .transaction(function(t) {
                 t
                 .executeSql('SELECT * FROM categories', [], function(transaction, resultSet) {
                             handler(transaction, resultSet);
                             }, DB.transactionErrorHandler
                             .bind(DB, "Error while selecting wordGroups"));
                 })
}

When i called this method i got this error message could not prepare statement(1 no such table) error code 5 table is avaibale

Please any suggestion or idea..

Piraba
  • 6,974
  • 17
  • 85
  • 135
  • 2
    Are you aware of all the changes you need to do in order to properly upgrade from 2.2.0 to 5.1.1? Here are some: http://docs.phonegap.com/en/3.4.0/guide_platforms_android_upgrading.md.html Did you upgrade/update the project as well as the phonegap? – Swiffy Aug 11 '15 at 10:54
  • 1
    Someone else was getting the same error as you on iOS: https://issues.apache.org/jira/browse/CB-1546 he was suggested the following: `You should change your db.transaction() call from: db.transaction(function, [], win, fail) to: db.transaction(function, fail, win)` – Swiffy Aug 11 '15 at 10:56
  • I got this error `" Uncaught TypeError: Failed to execute 'transaction' on 'Database': The callback provided as parameter 2 is not a function.", source: file:///android_asset/www/com/jsonParser.js` – Piraba Aug 11 '15 at 11:47
  • What I have changed is `DB.vocabDB.transaction(function(t) { t .executeSql('SELECT * FROM categories', function(transaction, resultSet) { alert("getGroupCategory == " + resultSet.row.length); handler(transaction, resultSet); }, DB.transactionErrorHandler .bind(DB, "Error while selecting wordGroups")); })` – Piraba Aug 11 '15 at 11:49
  • 1
    `DB.transactionErrorHandler.bind(DB, "Error while selecting wordGroups")` is not a function for some reason? – Swiffy Aug 11 '15 at 11:53

1 Answers1

3

I would suggest to start clean with 5.1.1. This way you can prevent problems that may easily be caused by upgrading the whole thing, and will keep you searching for the root of the problems.

This might sound like more work, but it pretty sure will be less of a hassle than upgrading, at least that is what my personal experience taught me with PhoneGap.

LilaQ
  • 349
  • 5
  • 19