求教大家:
模糊查询书按照书名-------------------
java.sql.SQLException: Illegal mix of collations (gb2312_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1448)
MySql中的编码集为:utf-8 或gbk 都试过了,还是出现这样的错误
jsp文件为utf-8的
我的查询语句为:
String sql="SELECT `books`.`id`, `books`.`book_name`,`books`.`price`,`books`.`book_info`," +
"`books`.`author`,`books`.`img_url` " +
" from `books` " +
"where `books`.`book_name` like ? ";
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, '%'+bkname+'%');
ResultSet rs=ps.executeQuery();
错在哪里,实在是找不出原因了。。。。
求助高手帮帮忙!!谢谢!!