Sqlite sqlite3_config 报错 21

前端之家收集整理的这篇文章主要介绍了Sqlite sqlite3_config 报错 21前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

要使用sqlite进行开发,需要用sqlite3_config()函数设置多线程模式,结果发现调用函数一直ERROR,错误码是21.查看了相关的错误码文档,不明所以。。。之后果断google,找到了问题的所在和解决方案:

I struggled long and hard with this as well and finally got the solution.

sqlite3_config() needs to be called before sqlite3_initialize(). However,the OS might initialize sqlite for us so I also do a sqlite3_shutdown() before the sqlite3_config() i.e. 1) sqlite3_shutdown() 2) sqlite3_config() 3) sqlite3_initialize().

Then its also necessary to use the same connection for every query as it is the access to the database connection that gets serialized. As described herehttp://www.sqlite.org/capi3ref.html#sqliteconfigserialized

So I create a connection as soon as the app starts up and the pass that connection to every class that needs it.

地址:http://stackoverflow.com/questions/7795973/setting-sqlite-config-sqlite-config-serialized-returns-sqlite-misuse-on-ios-5

原文链接:https://www.f2er.com/sqlite/200259.html

猜你在找的Sqlite相关文章