13

I m getting following error:while accessing database from two different threads using single database object throughout the application

The connection pool for database
'/data/data/msv_database.db' has been unable to grant a connection to thread 802 ( Connections: 0 active, 1 idle, 0 available.

1

2 Answers 2

11

Probably you want to select query on a table which is used on a transaction without ended transaction before. Try to execute endTransaction() on finally block of transaction.

OR

You are updating two tables and two different transactions are holding different tables waiting for the other to release.

OR

Simply that there are just too many open connections and the DB or connection pool just gets confused.

Whatever it is, something is probably wrong out of the above. Check carefully.

More - Connection pool has been unable to grant a connection to thread.

Sign up to request clarification or add additional context in comments.

Comments

0

I hope this is relevant to what you are facing. I am keeping a hold of SQLiteOpenHelper within a contentProvider. I was adding to my CRUD operations db.beginTransaction, db.setTransactionSuccessful, and db.endTransaction. I removed them, and that solved the issue I was having as I was calling my contentProvider from a loader and an intentService. Strange, many have mentioned that these commands are important to avoid the error.

https://github.com/juanmendez/jm_android_dev/blob/master/12.alarms/06.magazineAppWithAlarm/app/src/main/java/info/juanmendez/android/intentservice/service/provider/crud/MagazineCrud.java

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.