SQLite suddenly considers everything as not an error
Asked Answered
B

1

6

It started on an Android phone, simple create statement in a file inside the assets/migrations folder (I use a 3rd party library called ActiveAndroid and for 2 years it worked okay - I did not changed anything about that):

CREATE TABLE IF NOT EXISTS Car (Brand TEXT);

I get this exception:

04-07 15:31:36.683  15738-15738/? E/SQLiteLog﹕ (21) API called with NULL prepared statement
04-07 15:31:36.683  15738-15738/? E/SQLiteLog﹕ (21) misuse at line 63243 of [00bb9c9ce4]
java.lang.RuntimeException: Unable to create application com.activeandroid.app.Application: android.database.sqlite.SQLiteException: not an error (code 0)


at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4394)
            at android.app.ActivityThread.access$1300(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.database.sqlite.SQLiteException: not an error (code 0)
            at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
            at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:727)
            at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
            at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
            at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1665)
            at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
            at com.activeandroid.DatabaseHelper.executeSqlScript(DatabaseHelper.java:185)
            at com.activeandroid.DatabaseHelper.executeMigrations(DatabaseHelper.java:155)
            at com.activeandroid.DatabaseHelper.onUpgrade(DatabaseHelper.java:78)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:257)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
            at com.activeandroid.Cache.openDatabase(Cache.java:104)
            at com.activeandroid.Cache.initialize(Cache.java:77)
            at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:43)
            at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:30)
            at com.activeandroid.app.Application.onCreate(Application.java:25)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
            at android.app.ActivityThread.access$1300(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            at java.lang.reflect.Method.invokeNative(Native Method)

So I checked it on my computer with a Firefox addon called SQLite Manager and created a brand new file (the file is totally unrelated to the Android database). I used this select and on the last error I get this:

enter image description here

It seems that every SQLite statement is a not an error statement.

Unfortunately, Android can't handle that.

What should I do?

Benzoic answered 7/4, 2015 at 14:8 Comment(7)
API called with NULL prepared statement Can you show how do you query your table?Donielle
I use a 3rd party library, ActiveAndroid (and it works for 2 years now). Which method should I search for?Benzoic
The one to which you are passing the null prepared statement. Typically a query.Donielle
@DerGolem I do not use queries, that's the point of ORMs. I simply use the save method of the model object and it is saved via ActiveAndroid. As I said, it's been working for 2 years and nothing is changed in it. The curious thing is that the Firefox addon also shows not an error. Why? Is it common?Benzoic
This is why I hate 3rd party librares.Donielle
This 3rd party library has been working for 2 years without a problem and nothing has been changed in it (because it works). Can you explain why does the FF addon also show not an error message?Benzoic
No. I can't. I don't know the db structure. Maybe the db is cotrrupt. Maybe it lacks the master table, ....Donielle
B
21

It seems that the upgrade script in the assets\migration folder had some empty lines and that caused the not an error.

Benzoic answered 9/4, 2015 at 6:11 Comment(6)
Ah, it was driving me insane. The same is valid for Sugar ORM. Much thanks!Stannum
@dVaffection Glad it could help :)Benzoic
Thank you for answering this. It could really be a hard to find problem which your answer solved in 30sFeuillant
@BugsHappen Glad that the answer was helpful :)Benzoic
FYI, you can use the much improved SQL Parser that permits empty lines, comments and all sorts of stuff. As per: github.com/pardom/ActiveAndroid/pull/215#issuecomment-58227643Mcferren
I ran into this issue because my sql file contained comments! I was following along this tutorial for upgrading a database with the sqliteassethelper utility.Hoag

© 2022 - 2024 — McMap. All rights reserved.