Too many bind arguments. 5 arguments were provided but the statement needs 4 arguments(绑定参数太多.提供了 5 个参数,但语句需要 4 个参数)
问题描述
执行下面的函数时,我得到了上面的 IllegalArgumentException.我没有得到的是,当我运行调试器时,values 变量显然只包含 4 个参数,因为它应该.
I get the IllegalArgumentException above when executing the function below. What I don't get is that when I run the debugger, the values variable clearly only contains 4 arguments, as it should.
所以……
(1) 这个神秘的第五个论点从何而来?
(1) Where does this mysterious fifth argument come from?
(2) 我应该如何找到这个错误?
(2) How should I approach finding this error?
db.update(
UppdragEntry.TABLE_NAME,
values,
selection,
selectionArgs);
推荐答案
Selection 包含以下内容: String selection = "_id";String[] selectionArgs = {" =" + personId};
Selection contains the following: String selection = "_id"; String[] selectionArgs = {" =" + personId};
您在 selectionArgs
中有一个值,但在 selection
中没有 ?
占位符.
You have a value in selectionArgs
but no ?
placeholder for it in selection
.
改成
String selection = "_id = ?";
String[] selectionArgs = { "" + personId };
该方法构建一个 SQL 字符串.提供的 ContentValues
构建为 ?
占位符和绑定参数.额外的选择参数也作为绑定参数提供,它们必须与相同数量的 ?
占位符匹配.
The method builds an SQL string. Supplied ContentValues
are built as ?
placeholder and bind arguments. Additional selection args are also provided as bind arguments and they must be matched with equal number of ?
placeholders.
这篇关于绑定参数太多.提供了 5 个参数,但语句需要 4 个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:绑定参数太多.提供了 5 个参数,但语句需要 4 个参数


- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01