加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

解决SQLite异常:library routine called out of sequence

发布时间:2020-12-12 23:53:10 所属栏目:百科 来源:网络整理
导读:在平常的练习中出现了这样的问题,在网上搜寻了下,发现没有什么确定的答案。 却发现: Error Code SQLITE_MISUSE (21) "Library routine called out of sequence" The SQLITE_MISUSE error code is returned when you misuse the SQLitelibrary in some way

在平常的练习中出现了这样的问题,在网上搜寻了下,发现没有什么确定的答案。

却发现:

Error Code SQLITE_MISUSE (21) "Library routine called out of sequence"

The SQLITE_MISUSE error code is returned when you misuse the SQLitelibrary in some way. SQLite does not guarantee that it will detectmisuse,so you should not depend on this behavior in any way. TheSQLITE_MISUSE error code is intended to help you find the bugs inyour code.

Here are some possible causes of SQLITE_MISUSE:

  1. Calling any API routine with an sqlite3* pointer that was not obtained from sqlite3_open() or sqlite3_open16() or which has already been closed by sqlite3_close().
  2. Trying to use the same database connection at the same instant in time from two or more threads.
  3. Calling sqlite3_step() with a sqlite3_stmt* statement pointer that was not obtained from sqlite3_prepare() or sqlite3_prepare16() or that has already been destroyed by sqlite3_finalize().
  4. Trying to bind values to a statement (using sqlite3_bind_...()) while that statement is running.

这是SQLite官网上给出的问题解释。

1. 调用API所用到的指针,第一种情况是没有从sqlite3_open()或者是sqlite3_open16()获得,第二种情况是sqlite3_open()函数已经将数据库关闭了。我是第二种情况。

2. 两个或者更多的线程同时访问该数据库。对于这样的问题,可以通过加上锁进行解决。

3. sqlite3_step()所用到的变量statement指针,第一种情况是该指针不是从sqlite3_prepare()或者是sqlite3_open16()获得的,第二种情况是该指针已经被销毁或者被释放。这个和1中的情况是一样的,不同的是使用这种指针的函数,两者可以和为一种情况。

4. 试图将values绑定到一个正在运行的statement上。该解释未遇到。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读