1.java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters.
原代码(查询语句)
Cursor cursor = db.rawQuery("select * from message where user_name = '?' ", new String[]{currentUserName});
修改后(?这里去除了单引号)
Cursor cursor = db.rawQuery("select * from message where user_name = ? ", new String[]{currentUserName});
本文介绍了一个常见的SQL查询问题,即因参数索引超出范围导致的java.lang.IllegalArgumentException异常,并提供了解决方案。通过调整SQL语句中占位符的位置,确保其与提供的参数数量匹配。
7113

被折叠的 条评论
为什么被折叠?



