sqlite数据库异常汇总信息

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)

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能