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

sqlite数据库异常汇总信息

发布时间:2020-12-12 19:44:52 所属栏目:百科 来源:网络整理
导读:1.java.lang.IllegalArgumentException: the bind value at index 1(数字 从1开始 1代表条件中的第一个字段 ) is null 当预处理查询数据库时 where 子句里的条件参数值有null时将报该错误 如Cursor cursor=db.rawQuery("select * from user where name = ?

1.java.lang.IllegalArgumentException: the bind value at index 1(数字 从1开始 1代表条件中的第一个字段 ) is null

当预处理查询数据库时 where 子句里的条件参数值有null时将报该错误

如Cursor cursor=db.rawQuery("select * from user where name = ?",new String[]{null});

sql查询表中某个字段为null的记录时应该如下查询

Cursor cursor=db.rawQuery("select * from user where name is null",null);

sql查询表中某个字段不为null的记录时应该如下查询

Cursor cursor=db.rawQuery("select * from user where name is not null",null);

如果要查询的字段为int型 那木null代表0 即上面这条语句如果name为int型 则查询表中name不为0的记录

查询时条件语句中使用了is null 或 not null 时 如果表中某字段设置了索引 则查询时将不会使用索引 这时如果想使用索引则需变更sql中的where子句 如下

Cursor cursor=db.rawQuery("select * from user where name = ?",new String[]{"0"}); //name为int型

Cursor cursor=db.rawQuery("select * from user where name = ?",new String[]{"-100"}); //创建表时为name设置一个默认值(如-100)

(编辑:李大同)

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

    推荐文章
      热点阅读