数据库操作的异常Cannot perform this operation because the connection pool has been close

============问题描述============


异常日志如下:
Caused by: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.

	at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:962)

	at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:599)

	at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)

	at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)

	at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)

	at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)

	at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)

	at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)

	at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:196)

	at android.database.AbstractCursor.moveToNext(AbstractCursor.java:244)


我知道这是数据库连接被关闭导致的,但是怎么解决这个问题呢,网上能找到的解决办法都试了,还是会报这个问题,请教高人指点!

============解决方案1============


那就在使用后才关闭啊

============解决方案2============


是不是没有关闭cursor,然后再次访问造成的异常

============解决方案3============


光这么点代码难办啊,最好能描述下db的使用的流程

============解决方案4============


放线程里有问题,放服务里没问题?
是不是线程没执行完(数据库没来得及close)就强制结束了。

============解决方案5============


sqllite 是不支持多线程 同时 读写的,是不是这个问题?

转载于:https://www.cnblogs.com/llj1985522/p/4091530.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值