java写preparedStatement中的sql的like话语

java写preparedStatement中的sql的like语句今天写到这个,很郁闷,用了三种方法:PreparedStatementstat Co

java写preparedStatement中的sql的like语句
今天写到这个,很郁闷,用了三种方法:
PreparedStatement  stat ; Connection conn;
1:

stat = conn.PreparedStatement("select * from book where bookname like ?");stat.setString(1,"%"+bookname+"%");


这样最后终于达到模糊匹配查询功能。

还望各位高人告诉鄙人第一种方法为什么不行。在此谢过。 1 楼 Maplemirror 2011-07-28   http://hi.baidu.com/fei126222/blog/item/e35326d61468943d06088b66.html