0 Replies - 1644 Views - Last Post: 09 July 2018 - 02:16 PM

#1 TonyStarkissi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-July 18

Room Android: Unable to grant a connection to thread (Connection Pool

Posted 09 July 2018 - 02:16 PM

I have the following code using Room library to handle sqldatabase. I waSthe downloadCustomers method many times but all of a sudden i got the following message inside at the mDatabase.repoCustomer().deleteCustomers() :


*The connection pool for database has been unable to grant a connection to thread room android*

This happened only once and i wiped the emulator so i can run it again.
I read in forums that "*a transaction might be open by a thread*", but Room library handles automatically situations like these.

Any ideas?

**Emulator:** Emulator API 27 with Google Play (not Google APIs)

**Something to consider:** Sometimes when i run apps with Google play strange things happen e.x runs an app with 2 instances at the same time. But i dont want to make quick assumptions.

Thank you.

    public abstract class AppDatabase extends RoomDatabase {

    private static AppDatabase sInstance;

    public static final String DATABASE_NAME = "Database_db";

    public abstract CustomerDao repoCustomer();

    public static AppDatabase getInstance(Context context) {

        if (sInstance == null) {
            synchronized (AppDatabase.class) {
                if (sInstance == null) {
                    sInstance = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, DATABASE_NAME).build();
        return sInstance;

    public void downloadCustomers(final String table){

            executors.diskIO().execute(new Runnable() {
                public void run() {

                    if (mDatabase.repoCustomer().getAllCustomers().size() == 0) {

    public interface CustomerDao {

        @Transaction @Query("SELECT * FROM Customer")
        LiveData<List<Customer>> getAllCustomersLive();

        @Transaction @Query("SELECT * FROM Customer")
        List<Customer> getAllCustomers();

        @Transaction @Insert(onConflict = OnConflictStrategy.REPLACE)
        void insertCustomers(List<Customer> Customers);

        @Query("DELETE FROM Customer")
        int deleteCustomers();

Is This A Good Question/Topic? 0
  • +

Page 1 of 1