Home >Database >Mysql Tutorial >mysql-MySQL语句查询问题,异常和查询条件

mysql-MySQL语句查询问题,异常和查询条件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 09:34:371197browse

mysqlexception

源代码如下
switch (querryType) {
case 0:
hql = "from BookInfo b where b.bookName= '"+ querryKeys + "'''";
break;
case 1:
hql = "from BookInfo b where b.author='" + querryKeys + "'";
break;
case 2:
hql = "from BookInfo b where b.bookIsbn='" + querryKeys + "'";
break;
default:
hql = "from BookInfo b where b.bookName= '" + querryKeys +"'";
break;
}
很奇怪
使用http://localhost:8080/server/querry_book?querry_type=1&querry_keys=lvhaoyue
有查询结果如下
{"status":"200","message":"success","total":1,"result":[{"book_isbn":"13","book_name":"APP蓝图——Axure RP7.0移动互联网产品原型设计","author":"lvhaoyue"}]}
但是问题就是当我使用
http://localhost:8080/server/querry_book?querry_type=0&querry_keys=gongzhixiong查询时
报错如下
expecting ''', found '' [from org.yixing.entity.BookInfo b where b.bookName= gongzhixiong']; nested exception is org.hibernate.QueryException: expecting ''', found '' [from org.yixing.entity.BookInfo b where b.bookName= gongzhixiong']
在网找了半天也没办法解决,求解决。
另外就是当我改变查询条件当输入http://localhost:8080/server/querry_book?querry_type=0&querry_keys=小米时,返回成功但是result里面没有数据,不知道这个又怎么解决。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn