执行“END"时Sqlite数据库被锁定 [英] Sqlite database locked when executing "END"

查看:28
本文介绍了执行“END"时Sqlite数据库被锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了加快我在 iOS6 上的 Sqlite3 数据库上的数据库插入速度,我将插入内容包装在BEGIN"和END"命令中.数据库设置为以序列化模式运行.有趣的是,我在执行END"时遇到异常:错误说数据库被锁定.好吧,我希望它会被锁定,毕竟据我所知,我正在进行交易.有人能解释一下什么条件会导致这种行为吗?

In order to speed up my DB insertions on an Sqlite3 DB on iOS6, I'm wrapping the inserts in "BEGIN" and "END" commands. The DB is set to run in serialized mode. The interesting thing is that I'm getting an exception when executing the "END": the error says the DB is locked. Well, I expect it to be locked, after all I'm in a transaction as far as I can tell. Can somebody explain what conditions could cause this behavior?

推荐答案

我发现了问题.要使序列化访问工作,您可能只有一个连接.在我的测试项目中,我忘记实现连接缓存.通过这种方式,我最终为每个数据库建立了相当多的(打开的)连接.

I found the problem. To make serialized access work, you may have only one connection. In my test project I forgot to implement the connection cache. This way I ended up with quite many (open) connections for each database.

这篇关于执行“END"时Sqlite数据库被锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆