Intermittent Sqliteexception: Not An Error At Dbopen
Solution 1:
I have also received this same error when passing an empty string for query.
Solution 2:
This error is coming from the statement getWritableDatabase where you are trying to create / open database.
From the code segment what you have given , i see that you are trying to open the database for each operation.
This is not the right way to do it. You have to open your DB only once before you close it . Normal practise is open it during your other initialisation and take care to close it before exit the app . Once open store the db context and use that in all other operations
for eg : you can have a database manegr class like this :
public DataBaseManager open() throws SQLException {
try {
mDbHelper = new DatabaseHelper(mCtx);
mDb = mDbHelper.getWritableDatabase();
} catch (Exception ex) {
ex.printStackTrace();
Utils.getHomeActivityinstance().finish();
}
returnthis;
}
now when delte need to be called, do not call open again
publicbooleandeleteRow(String tableName, long rowId) {
return mDb.delete(tableName, ID + "=" + rowId, null) > 0;
}
Solution 3:
It looks like your query is bad on the not
.
Looking at the SQLite Docs, according to them there isn't a not
in the way you are trying to use it (as a negation of your where).
Your choices for not appear to be:
NOTLIKENOT GLOB
NOT REGEXP
NOTMATCHNOTBETWEENNOTINISNOT
And most of those require an expression before them.
WHERE xxxx NOTMATCH yyyy
Solution 4:
Make sure your query doesn't contain trailing empty lines after semicolon ";" of your query.
I had the same issue executing queries inside a Sqlite Client, after poking around I found the problem is that I had two empty lines below the query.
In case anyone encountered the same issue, here are a few pass/fail cases inside Sqlite client (or loading a .sql
file ).
Good:
-- test.sqlSELECT*FROMtable;
Good:
-- test2.sql-- notice the empty line below doesn't break the codeSELECT*FROMtable;
Good:
-- test3.sql-- notice the query string is not terminated by semicolon ";"-- but it does contain trailing empty linesSELECT*FROMtable-- this line is just a placeholder, in actual file this line should also be empty
Bad:
-- test3.sql-- notice the query string is terminated with semicolon, -- and there are trailing empty lines after thatSELECT*FROMtable;
-- this line is just a placeholder, in actual file this line should also be empty
Hope this helps.
Solution 5:
I spent two hours looking for solution to this problem, which was the reason I could not create table in SQLite database.
My error was that I had "is_selected" attribute and this caused NOT AN ERROR error. Renamed the attribute and it worked.
Post a Comment for "Intermittent Sqliteexception: Not An Error At Dbopen"