日期:2014-05-20  浏览次数:20727 次

不知道怎么错
在我的java代码中进行查询的时候,我使用如下语句
PreparedStatement pstmt=conn.prepareStatement("select * from book where bookName like ?%");
但却报错如下:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' at line 1

这是什么问题啊,大神指导啊!!!

------解决方案--------------------
select * from book where bookName like ?% -------

select * from book where bookName like '?%'

要加上单引号,注意基础知识。?% 这代码表示,?开头,后面跟无数任意字符。

祝你好运。