【发布时间】:2015-01-02 14:48:21
【问题描述】:
我正在使用 Phonegap 开发一个移动应用程序。我的应用程序中有一个 web sql 数据库。首次启动应用程序时,会创建并填充数据库。在我用于创建数据库的代码下方:
var db = window.openDatabase('littera', '1.0', 'Littera DB', 5 * 1024 * 1024);
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS quote (id integer primary key, author_id integer, category text, content text, favourite integer)');
tx.executeSql('CREATE TABLE IF NOT EXISTS author (id integer primary key, name text, short_bio text, media text)');
callback();
}, function(e) {
console.log("ERROR CREATING DB: " + e.message);
callback();
});
我第一次启动应用程序时,会发生以下与数据库创建相关的错误(请注意,这只发生在第一次,该应用程序在所有其他启动时都能正常运行):
01-01 23:57:41.600: E/SQLiteLog(1944): (1) no such table: CacheGroups
01-01 23:57:41.600: D/WebKit(1944): ERROR:
01-01 23:57:41.600: D/WebKit(1944): Application Cache Storage: failed to execute statement "DELETE FROM CacheGroups" error "no such table: CacheGroups"
01-01 23:57:41.600: D/WebKit(1944): external/webkit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558) : bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&)
01-01 23:57:41.600: E/SQLiteLog(1944): (1) no such table: Caches
01-01 23:57:41.600: D/WebKit(1944): ERROR:
01-01 23:57:41.600: D/WebKit(1944): Application Cache Storage: failed to execute statement "DELETE FROM Caches" error "no such table: Caches"
01-01 23:57:41.600: D/WebKit(1944): external/webkit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558) : bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&)
01-01 23:57:41.600: E/SQLiteLog(1944): (1) no such table: Origins
01-01 23:57:41.600: D/WebKit(1944): ERROR:
01-01 23:57:41.600: D/WebKit(1944): Application Cache Storage: failed to execute statement "DELETE FROM Origins" error "no such table: Origins"
01-01 23:57:41.600: D/WebKit(1944): external/webkit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558) : bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&)
01-01 23:57:41.600: E/SQLiteLog(1944): (1) no such table: DeletedCacheResources
产生错误的表不是我自己的表,而是web sql在幕后为自己施展魔法而创建的一些表。我想在数据库创建过程中出了点问题,因为我在以后的启动中没有同样的错误。我错过了什么吗?
【问题讨论】: