Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Çó¾ÈMySqlÄ£ºý²éѯÎÊÌâ

Java code:

Ä£ºý²éѯÊé°´ÕÕÊéÃû-------------------
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 ¶¼ÊÔ¹ýÁË£¬»¹ÊdzöÏÖÕâÑùµÄ´íÎó

jspÎļþΪutf-8µÄ

ÎҵIJéѯÓï¾äΪ£º

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();

´íÔÚÄÄÀʵÔÚÊÇÕÒ²»³öÔ­ÒòÁË¡£¡£¡£¡£

ÇóÖú¸ßÊÖ°ï°ï棡£¡Ð»Ð»£¡£¡
²¹³ä


Ïà¹ØÎÊ´ð£º

Çómysql+php ÖÐÎÄÈ«ÎÄËÑË÷

×ö¸öÕ¾ÄÚËÑË÷£¬ÏÖÔÚÓÃlike ÕâÑùµÄЧÂÊʵÔÚÌ«µÍÁË£¬Ïë¸Ä³ÉÈ«ÎÄËÑË÷·½Ê½¡£

µ«¿´ÁËÍøÉÏ˵µÄÖÐÎÄÖ§³Ö²»ºÃ£¬ÏëÎÊһϸ÷λÐÖµÜÊÇÈçºÎ½â¾öÕâ¸öÎÊÌâµÄ£¿
µ¥¶À½¨Á¢Ö÷Ìâ±íºÍÄÚÈÝ±í ¼ìË÷Ö÷Ìâ

È»ºó¸ù¾ÝÖ÷Ìâ¼ìË÷Ä ......

ÈçºÎÓÃjspʵÏÖmysqlÊý¾Ý¿â±àÂ룿

ÔÚphpÖÐÓÃÕâ¾ä¾Í¿ÉʵÏÖ¶Ô¿Í»§¶Ë×Ö·û¼¯µÄÉèÖÃ....

mysql_query("set names gb2312")

ÇëÎÊÔÚjspÖÐÈçºÎʵÏÖÕâ¾ä¹¦ÄÜ£¿£¿£¿
jspÖУº
<%@page language="java" contentType=&q ......

mysql Ð޸IJéѯÊý¾ÝµÄÎÊÌâ

select time from table

time
2009-09-12 12
2009-09-12 13
2009-09-12 14
2009-09-12 15

Ôõô½« ²éѯµÄÊý¾Ý±äΪ
time
2009-09-12 12ʱ
2009-09-12 13ʱ
2009-09-12 14ʱ
......

mysqlµÄ sequence µÄÎÊÌâ¡£ÔÚÏߵȴý¡£¡£

ÇëÎÊһϣ¬mysqlµÄsequenceÊÇ×Ô¶¯µÝÔöµÄ£¬²»ÐèÒª½øÐвÙ×÷¡£
ÄÇÎÒÔÚ²åÈëÒ»ÌõÖ÷¼Ç¼µÄʱºò£¬Í¬Ê±Òª¸øÕâ¸öÖ÷¼üµÄÆäËû±í½øÐвåÈëÊý¾Ý¡£Õâʱºò£¬ÎÒ¸ù±¾È¡²»µ½Õâ¸öµÝÔöµÄsequence°¢¡£¡£

Õâ¸öÎÊÌâÔõô½â¾ö°¢¡£¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ