Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting exception code 8 #797

Open
NileshSystematix opened this issue Jul 5, 2018 · 7 comments
Open

Getting exception code 8 #797

NileshSystematix opened this issue Jul 5, 2018 · 7 comments

Comments

@NileshSystematix
Copy link

NileshSystematix commented Jul 5, 2018

Getting Exception code 8 after several attempts of insert/update. Below is the query & result error code.

UPDATE log_table SET sync_status=0 WHERE tablename = 'trip_table'
Exception code: 8

Exception

7-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: java.sql.SQLException: sqlite3_step failure: attempt to write a readonly database
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.liteglue.SQLiteGlueConnection$SQLGStatement.step(SQLiteGlueConnection.java:135)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.sqlc.SQLiteConnectorDatabase.executeSQLiteStatement(SQLiteConnectorDatabase.java:214)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.sqlc.SQLiteConnectorDatabase.executeSqlBatch(SQLiteConnectorDatabase.java:114)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.sqlc.SQLitePlugin$DBRunner.run(SQLitePlugin.java:340)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at java.util.concurrent.ThreadPoolExecuto

@brodycj
Copy link
Contributor

brodycj commented Jul 5, 2018

Closing for multiple reasons:

@brodycj brodycj closed this as completed Jul 5, 2018
@NileshSystematix
Copy link
Author

NileshSystematix commented Jul 5, 2018

Sorry Chris,

Platform : Android
Android : 4.4.2
Scenario :

Our app have regress interaction with database for Insert/Update & Select. After some 15-20 transaction, the "Update" & "Insert" query tends to fail in executing. The SQLException 8 is coming. These queries are running in background thread. Simultaneously we are performing some action on the JS side due to which we are getting the following exception

SQL Query Causing issue after some successful executions is, "UPDATE log_table SET sync_status=0 WHERE tablename = 'trip_table'"
Response Exception code: 8

Exception Stacktrace

7-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: java.sql.SQLException: sqlite3_step failure: attempt to write a readonly database
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.liteglue.SQLiteGlueConnection$SQLGStatement.step(SQLiteGlueConnection.java:135)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.sqlc.SQLiteConnectorDatabase.executeSQLiteStatement(SQLiteConnectorDatabase.java:214)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.sqlc.SQLiteConnectorDatabase.executeSqlBatch(SQLiteConnectorDatabase.java:114)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at io.sqlc.SQLitePlugin$DBRunner.run(SQLitePlugin.java:340)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-05 06:25:24.621 14553-14649/com.sipl.dtdc W/System.err: at java.util.concurrent.ThreadPoolExecuto

Looking forward for your support.

@brodycj
Copy link
Contributor

brodycj commented Jul 5, 2018

Please explain how you are accessing the database. Accessing the same database outside the plugin is not supported and may lead to "multiple sqlite problem" as discussed in documentation and multiple issues.

If you do need to access the same database outside of this plugin the workaround is to open the database with the androidDatabaseImplementation: 2 setting, as documented.

@brodycj brodycj reopened this Jul 5, 2018
@NileshSystematix
Copy link
Author

Hello Chris,

BElow is my DB adapter file url. Can you please check this:

https://drive.google.com/file/d/1il6HLzfyCphVzv0WCv1SnSrKl0BjGk_l/view?usp=sharing

@brodycj
Copy link
Contributor

brodycj commented Jul 5, 2018

So it looks to me like you are accessing the same database from both the plugin and the custom DB adapter. In this case you have to open the database with the androidDatabaseImplementation: 2 setting, as documented in the README file. I hope to get this better documented in the near future.

If you do not use the androidDatabaseImplementation: 2 setting you have the "multiple sqlite problem" as discussed in README.md and multiple issues. Marking as a "data loss risk" issue though it is not really a bug on this plugin.

P.S. Linking to https://stackoverflow.com/questions/1518729/change-sqlite-database-mode-to-read-write for reference

@NileshSystematix
Copy link
Author

Hello Chris,

I have used this but it is not resolving my issue. Can you please help me sort this issue?

Multiple SQLite problem on Android
This plugin uses a non-standard Android-sqlite-connector implementation on Android. In case an application access the SAME database using multiple plugins there is a risk of data corruption ref: #626) as described in http://ericsink.com/entries/multiple_sqlite_problem.html and https://www.sqlite.org/howtocorrupt.html.

The workaround is to use the androidDatabaseImplementation: 2 setting as described in the Android sqlite implementation section below:

var db = window.sqlitePlugin.openDatabase({
name: 'my.db',
location: 'default',
androidDatabaseImplementation: 2
});

@brodycj
Copy link
Contributor

brodycj commented Jul 5, 2018

Hi @NileshSystematix,

At this point I think the best approach would be to start with a really simple app, with a really simple database adapter, using the androidDatabaseImplementation: 2 on the JavaScript side, and try one thing at a time until you can determine what does and does not work properly.

I will be available later today or tonight to work with you if necessary, will contact you privately about the pricing.

@storesafe storesafe deleted a comment from NileshSystematix Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants