Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错
做模糊搜索时,出现了 bind or column index out of range: handle 0x2fb180 报错
public Cursor getTitle(String word) throws SQLException{
String sql = "select * from contentinfo1 where title =? ";
Cursor cursor = db.rawQuery(sql, new String[] {word});
return cursor;
}
实现精确匹配后,依葫芦画瓢的想制作模糊搜索,套用了SQL语句,不料出错
public Cursor getTitle(String word) throws SQLException{
String sql = "select * from contentinfo1 where title like '%"+word+"%'";
Cursor cursor = db.rawQuery(sql, new String[] {word});
return cursor;
}
解决方法:
public Cursor getTitle(String word) throws SQLException{
String sql = "select * from contentinfo1 where title like '%"+word+"%'";
Cursor cursor = db.rawQuery(sql,null);
return cursor;
}
原因:更改语句之后用了+word+而非占位符 ?, 所以rawQuery第二个参数不知道和哪个对应故出现报错
进一步修改方案可以参照
http://stackoverflow.com/questions/5716543/android-sqliteexception-bind-or-column-index-out-of-range-problem
需要将第二个rawquery参数更改为NULL
Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错的更多相关文章
- java.sql.SQLException:Column Index out of range,0<1
1.错误描述 java.sql.SQLException:Column Index out of range,0<1 2.错误原因 try { Class.forName("com.m ...
- Column Index out of range, 2 > 1 列索引的范围,2 > 1。
Column Index out of range, 2 > 1 列索引的范围,2 > 1.这个问题是进行数据库查询的时候出现的. 因为查询sql语句时 只查询了 name 然后whil ...
- Android调用 .Net Core WebApi 返回数据,用FastJSON解析一直报错。
问题描述:.Net Core WebApi中用Newtonsoft.Json 把datatable转成json字符串,如:JsonConvert.SerializeObject(table,Forma ...
- android studio 解析Excel数据格式导入poi-3.17.jar时的一系列报错及处理Failed resolution of: Ljavax/xml/stream/XMLEventFactory,duplicate entry: org/apache/xmlbeans/xml/stream/Location.class,GC overhead limit exceeded
在org官网下载的poi jar包,导入到studio compile files('libs/poi-3.17.jar') compile files('libs/poi-ooxml-3.17.ja ...
- android The public type classname must be defined in its own file 报错
The public type classname must be defined in its own file classname 为类名 错误提示,公用的类必髯有自己拥有独立.java文件 解 ...
- Android 解决安装Egit时Egit Mylyn和org.eclipse.team.core报错
为了让Aptana支持GitHub,需要安装Egit,但在的时候碰到两个错误,一个是关于缺少EGit Mylyn另一个是缺少org.eclipse.egit.import.feature.group. ...
- 解决 在Android开发上使用KSOAP2上传大图片到服务器经常报错的问题
原文首发我的主力博客 http://anforen.com/wp/2017/04/android_ksoap2_unexpected_type_position_end_document_null_j ...
- eclipse里index.jsp头部报错的原因和解决方法
index.jsp的头<%@这句报错的话,是因为没有引入Tomcat的原因.解决:A:Window---Preferences---server---RuntimeEnviroments--Ad ...
- mysql 5.7 ERROR 1054(42S22) Unknown column 'password' in ‘field list’ 报错
mysql 忘记密码 报错?ERROR 1054(42S22) Unknown column 'password' in ‘field list’原因:5.7版本下的mysql数据库下已经没有pass ...
随机推荐
- spring-boot和redis的缓存使用
1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.Maven Plugin管理 pom.xml配置代码: <?xml versio ...
- delphi String 与 Stream的互转
stream1 := TStringStream.create(str); str := TStringStream(stream1).DataString; Stream 是抽像类, ...
- APIO2019 练习赛 Wedding cake——思路+高精度
题目大意: 给 n ( n<=1e5 ) 个数 \( a_i \) (\( a_i \) <=1e5),需要构造 n 个实数使得它们的和是 1 ,并且第 i 个实数必须小数点后恰好有 \( ...
- [CSP-S模拟测试74]题解
A.梦境 如果不用去重一定要用Multiset……挂30分算是出题人手下留情了. 贪心.把点排序,区间按右端点递增排序.依次考虑每个区间,取能选的最靠左的点即可.multiset维护. #includ ...
- Linux 学习 (五) DNS配置
没有配置DNS会引起的问题 yum命令 ssh命令等不能进行 错误: Could not resolve host: centos.ustc.edu.cn; 本文例子: CentOS7 下DNS配置 ...
- soj#552 449E Jzzhu and Squares
分析 https://www.cnblogs.com/Memory-of-winter/p/11209128.html 代码 #include<bits/stdc++.h> using n ...
- 老牌激活工具 — Microsoft Toolkit 2.5.1正式版【转】
老牌激活工具 — Microsoft Toolkit 2.5.1正式版 Microsoft Toolkit 2.5.1是一个一键激活MS Office 及 win系统的工具.原理就是利用KMS来激活 ...
- xcodebuild自动打包上传到蒲公英的shell脚本
注意: ExportOptions.plist (包含了证书相关信息) 该plist 文件可以通过xcode手动导出ipa之后获取到, 区分appstore 和 development的情况 #! / ...
- python 简易计算器
import tkinter import tkinter.messagebox import math ''' 波波版计算器可实现的功能 1.能进行简单的加减惩处 2.能进行开根号操作 3.能进行后 ...
- 转 使用Python的logging.config.fileConfig配置日志
Python的logging.config.fileConfig方式配置日志,通过解析conf配置文件实现.文件 logglogging.conf 配置如下: [loggers]keys=root,f ...