首页 >数据库 >mysql教程 >mysql-MySQL语句查询问题,异常和查询条件

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

WBOY
WBOY原创
2016-06-06 09:34:371188浏览

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里面没有数据,不知道这个又怎么解决。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn