javascript - phonegap Sqlite plugin implementation-error and warning:no such table - Stack Overflow

I implemented the Phonegap plugin as mentioned in my previous question.I am getting an error as there i

I implemented the Phonegap plugin as mentioned in my previous question.

I am getting an error as there is no such table as given in query.whereas there is a table in that name.

CODE

    <script type="text/javascript" charset="utf=8" src="cordova-2.5.0.js"></script> 
    <script type="text/javascript" charset="utf-8" src="main.js"></script>
    <script type="text/javascript" charset="utf-8" src="SQLitePlugin.js"></script>
    <script type="text/javascript" charset="utf-8">

    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() 
    {
        var db =  window.sqlitePlugin.openDatabase("abc.db", "1.0", "test", 20000);

        db.transaction(function(tx) 
        {
            tx.executeSql("SELECT column_name FROM table_name;", [], function(tx) 
            {
                console.log("column_name length: " + column_name.length);

          });
        }, 
        function(e) 
        {
        console.log("ERROR: " + e.message);
        });

      }

  </script>

**Error and Warnings**

    04-12 18:11:58.271: D/dalvikvm(400): VFY: dead code 0x0047-0067 in L/phonegap/plugin/sqlitePlugin/SQLitePlugin;.results2string (Landroid/database/Cursor;)Ljava/lang/String;
    04-12 18:11:58.281: V/info(400): Open sqlite db: /data/data/.a.android.b/databases/abc.db.db
    04-12 18:11:58.351: D/CordovaLog(400): SQLitePluginTransaction - this.trans_id:1365770518342000
    04-12 18:11:58.351: I/Web Console(400): SQLitePluginTransaction - this.trans_id:1365770518342000 at file:///android_asset/www/SQLitePlugin.js:83
    04-12 18:11:58.351: D/CordovaLog(400): SQLitePluginTransaction.prototype.executeSql
    04-12 18:11:58.362: I/Web Console(400): SQLitePluginTransaction.prototype.executeSql at file:///android_asset/www/SQLitePlugin.js:164
    04-12 18:11:58.362: D/CordovaLog(400): success not null:SELECT column_name FROM table_name;
    04-12 18:11:58.362: I/Web Console(400): success not null:SELECT type FROM tpl_category; at file:///android_asset/www/SQLitePlugin.js:171
    04-12 18:11:58.362: D/CordovaLog(400): executeSql - add_to_transactionSELECT column_name FROM table_name;
    04-12 18:11:58.362: I/Web Console(400): executeSql - add_to_transactionSELECT column_name FROM table_name; at file:///android_asset/www/SQLitePlugin.js:199
    04-12 18:11:58.383: D/CordovaLog(400): SQLitePluginTransaction.prototypeplete
    04-12 18:11:58.383: I/Web Console(400): SQLitePluginTransaction.prototypeplete at file:///android_asset/www/SQLitePlugin.js:204
    04-12 18:11:58.391: I/Database(400): sqlite returned: error code = 1, msg = no such table: tpl_category
    04-12 18:11:58.391: W/System.err(400): android.database.sqlite.SQLiteException: no such table: table_name: , while piling: SELECT column_name FROM table_name;
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteCompiledSql.native_pile(Native Method)
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteCompiledSqlpile(SQLiteCompiledSql.java:91)
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
    04-12 18:11:58.401: W/System.err(400):  at .phonegap.plugin.sqlitePlugin.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:263)
    04-12 18:11:58.401: W/System.err(400):  at .phonegap.plugin.sqlitePlugin.SQLitePlugin.execute(SQLitePlugin.java:109)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:61)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.api.PluginManager.exec(PluginManager.java:220)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:44)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:221)
    04-12 18:11:58.401: W/System.err(400):  at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566)
    04-12 18:11:58.401: W/System.err(400):  at android.os.Handler.dispatchMessage(Handler.java:99)
    04-12 18:11:58.401: W/System.err(400):  at android.os.Looper.loop(Looper.java:123)
    04-12 18:11:58.412: W/System.err(400):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    04-12 18:11:58.412: W/System.err(400):  at java.lang.reflect.Method.invokeNative(Native Method)
    04-12 18:11:58.412: W/System.err(400):  at java.lang.reflect.Method.invoke(Method.java:521)
    04-12 18:11:58.412: W/System.err(400):  at .android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    04-12 18:11:58.412: W/System.err(400):  at .android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    04-12 18:11:58.412: W/System.err(400):  at dalvik.system.NativeStart.main(Native Method)
    04-12 18:11:58.412: V/executeSqlBatch(400): SQLitePlugin.executeSql(): Error=no such table: table_name: , while piling: SELECT column_name FROM table_name;
    04-12 18:11:58.412: V/executeSqlBatch(400): 1365770518342000
    04-12 18:11:58.432: D/CordovaLog(400): SQLitePluginTransaction.txErrorCallback---transId:1365770518342000
    04-12 18:11:58.432: I/Web Console(400): SQLitePluginTransaction.txErrorCallback---transId:1365770518342000 at file:///android_asset/www/SQLitePlugin.js:132
    04-12 18:11:58.444: D/CordovaLog(400): ERROR: undefined
    04-12 18:11:58.444: I/Web Console(400): ERROR: undefined at file:///android_asset/www/view all.html:27

Have I missed any initialization or declaration?

I implemented the Phonegap plugin as mentioned in my previous question.

I am getting an error as there is no such table as given in query.whereas there is a table in that name.

CODE

    <script type="text/javascript" charset="utf=8" src="cordova-2.5.0.js"></script> 
    <script type="text/javascript" charset="utf-8" src="main.js"></script>
    <script type="text/javascript" charset="utf-8" src="SQLitePlugin.js"></script>
    <script type="text/javascript" charset="utf-8">

    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() 
    {
        var db =  window.sqlitePlugin.openDatabase("abc.db", "1.0", "test", 20000);

        db.transaction(function(tx) 
        {
            tx.executeSql("SELECT column_name FROM table_name;", [], function(tx) 
            {
                console.log("column_name length: " + column_name.length);

          });
        }, 
        function(e) 
        {
        console.log("ERROR: " + e.message);
        });

      }

  </script>

**Error and Warnings**

    04-12 18:11:58.271: D/dalvikvm(400): VFY: dead code 0x0047-0067 in L/phonegap/plugin/sqlitePlugin/SQLitePlugin;.results2string (Landroid/database/Cursor;)Ljava/lang/String;
    04-12 18:11:58.281: V/info(400): Open sqlite db: /data/data/.a.android.b/databases/abc.db.db
    04-12 18:11:58.351: D/CordovaLog(400): SQLitePluginTransaction - this.trans_id:1365770518342000
    04-12 18:11:58.351: I/Web Console(400): SQLitePluginTransaction - this.trans_id:1365770518342000 at file:///android_asset/www/SQLitePlugin.js:83
    04-12 18:11:58.351: D/CordovaLog(400): SQLitePluginTransaction.prototype.executeSql
    04-12 18:11:58.362: I/Web Console(400): SQLitePluginTransaction.prototype.executeSql at file:///android_asset/www/SQLitePlugin.js:164
    04-12 18:11:58.362: D/CordovaLog(400): success not null:SELECT column_name FROM table_name;
    04-12 18:11:58.362: I/Web Console(400): success not null:SELECT type FROM tpl_category; at file:///android_asset/www/SQLitePlugin.js:171
    04-12 18:11:58.362: D/CordovaLog(400): executeSql - add_to_transactionSELECT column_name FROM table_name;
    04-12 18:11:58.362: I/Web Console(400): executeSql - add_to_transactionSELECT column_name FROM table_name; at file:///android_asset/www/SQLitePlugin.js:199
    04-12 18:11:58.383: D/CordovaLog(400): SQLitePluginTransaction.prototype.plete
    04-12 18:11:58.383: I/Web Console(400): SQLitePluginTransaction.prototype.plete at file:///android_asset/www/SQLitePlugin.js:204
    04-12 18:11:58.391: I/Database(400): sqlite returned: error code = 1, msg = no such table: tpl_category
    04-12 18:11:58.391: W/System.err(400): android.database.sqlite.SQLiteException: no such table: table_name: , while piling: SELECT column_name FROM table_name;
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteCompiledSql.native_pile(Native Method)
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteCompiledSql.pile(SQLiteCompiledSql.java:91)
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
    04-12 18:11:58.391: W/System.err(400):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
    04-12 18:11:58.401: W/System.err(400):  at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
    04-12 18:11:58.401: W/System.err(400):  at .phonegap.plugin.sqlitePlugin.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:263)
    04-12 18:11:58.401: W/System.err(400):  at .phonegap.plugin.sqlitePlugin.SQLitePlugin.execute(SQLitePlugin.java:109)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:61)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.api.PluginManager.exec(PluginManager.java:220)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:44)
    04-12 18:11:58.401: W/System.err(400):  at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:221)
    04-12 18:11:58.401: W/System.err(400):  at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566)
    04-12 18:11:58.401: W/System.err(400):  at android.os.Handler.dispatchMessage(Handler.java:99)
    04-12 18:11:58.401: W/System.err(400):  at android.os.Looper.loop(Looper.java:123)
    04-12 18:11:58.412: W/System.err(400):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    04-12 18:11:58.412: W/System.err(400):  at java.lang.reflect.Method.invokeNative(Native Method)
    04-12 18:11:58.412: W/System.err(400):  at java.lang.reflect.Method.invoke(Method.java:521)
    04-12 18:11:58.412: W/System.err(400):  at .android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    04-12 18:11:58.412: W/System.err(400):  at .android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    04-12 18:11:58.412: W/System.err(400):  at dalvik.system.NativeStart.main(Native Method)
    04-12 18:11:58.412: V/executeSqlBatch(400): SQLitePlugin.executeSql(): Error=no such table: table_name: , while piling: SELECT column_name FROM table_name;
    04-12 18:11:58.412: V/executeSqlBatch(400): 1365770518342000
    04-12 18:11:58.432: D/CordovaLog(400): SQLitePluginTransaction.txErrorCallback---transId:1365770518342000
    04-12 18:11:58.432: I/Web Console(400): SQLitePluginTransaction.txErrorCallback---transId:1365770518342000 at file:///android_asset/www/SQLitePlugin.js:132
    04-12 18:11:58.444: D/CordovaLog(400): ERROR: undefined
    04-12 18:11:58.444: I/Web Console(400): ERROR: undefined at file:///android_asset/www/view all.html:27

Have I missed any initialization or declaration?

Share Improve this question edited May 23, 2017 at 11:57 CommunityBot 11 silver badge asked Apr 12, 2013 at 13:03 useruser 1,0014 gold badges21 silver badges46 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 1

Well i found the answer to this post of mine. But this has put me into a new problem.

ASSUMPTIONS made by me...

I had put the .sqlite in the assets/www folder.so i assumed that the eclipse is opening that particular sqlite folder.

Code:

var db =  window.sqlitePlugin.openDatabase("abc.db", "1.0", "test", 20000);

Database formed was abc.db.db.that was my another mistake.So,when i gave the mand to access the tables through the mand

tx.executeSql("SELECT column_name FROM table_name;", [], function(tx) 
    {
        console.log("column_name length: " + column_name.length);

  });
}, 
function(e) 
{
console.log("ERROR: " + e.message);
});

it showed me an error as no such table_name.

IN FACT,IT CREATED A NEW .DB FILE(according to my code)WHICH DID NOT HAVE SUCH A TABLE INSIDE IT.

it was fully my mistake.

but,this makes me think further how am i gonna make eclipse access my .sqlite file,to integrate it for my Phonegap application?

ANY SUGGESTIONS AND SOLUTIONS PLEASE LET ME KNOW..

I think there is a bug in Cordova 2.6, I just upgraded from 2.5 today and all my sqlite code seems to have broke though I did make some other changes. I keep getting the same error but am 90% sure its cordova related.

04-17 02:21:08.722: E/Web Console(1698): "no such table: api (code 1): , while piling: SELECT * FROM api WHERE md5 = ? LIMIT 1" at file:///android_asset/www/js/app.js:9249

But I don't get any errors when I create the database and tables AND I can directly explore the database within eclipse using the file explorer and see that not only the database exists but the table is there as well.

Ill report any solution i find.

EDIT: I rolled back to cordova 2.5 and everything seems to be working for me now. That might work as a temporary fix until the issue is tracked down.

check this and follow this its working!

Have phonegap OF 2.1.0 version android OF 2.2 Jquery OF 1.8.2min(if you use)i did not use Jquery.

I TRIED THE SAME WITH THE RECENT VERSION OF PHONEGAP 2.5.0, ANDROID 4.1.2 & NEW SQLITE PLUGIN UPDATED 7 MONTHS AGO...IT DID NOT WORK....

FINALLY AFTER ALMOST 4-5 DAYS I FOUND A SOLUTION!!

YIPEE!!

Please refer below link, it's working for me.

http://docs.phonegap./en/2.5.0/cordova_storage_storage.md.html#Storage

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745653006a4638377.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信