MYSQLÊý¾Ý¿âµÄÖÐÎÄÎÊÌâ
ÖÐÎÄÏÔʾÎÊÌâÒ»Ö±ÊÇÀ§ÈÅÎÒÃǵÄÒ»¸öÄÑÌ⣬²»ÐÅÄãÉÏgoogleËÑË÷һϣ¬ÕâÀàµÄÎÊÌâºÍ½â´ð¿ÉÒÔ˵ÊÇÆÌÌì¸ÇµØ£¬ºÃ¶àÍøÕ¾ÉõÖÁ½«ÆäÌá³öÀ´×÷ΪרÌâÀ´ÌÖÂÛ£¬¹ÜÖпú±ª£¬¿É¼ûÒ»°ß¡£
¿ªÊ¼Ò²ÔøΪÕâ¸öÎÊÌâÍ·ÌÛ£¬ÉÏÍø²éÔÄ´óÁ¿µÄ×ÊÁϺͽâ¾ö·½·¨£¬ÖÕÓÚÕÒµ½ÁËÒ»Öּȼòµ¥ÓÖºÃÓõİ취£¬ÒÔJSP+MYSQL´æ´¢ÎªÀý£¬¼òµ¥½éÉÜһϡ£
ÅäÖãº
Winxp+Tomcat5.0+Mysql5.0
µ±Ò³Ãæ<%@ page contentType="text/html;charset=gbk"%>ʹÓÃGBK(»òÕßGB2312)±àÂëºó£¬Ò³ÃæÖеÄÖÐÎĶ¼¿ÉÒÔÕý³£ÏÔʾ(<%out.println("ÄÜÕý³£ÏÔʾÖÐÎÄÂð£¿");%>)¡£µ«ÊÇÉæ¼°µ½Êý¾Ý¿âµÄ´æȡʱ£¬Äú³£³£»á¿´µ½ÁîÈËÍ·ÌÛµÄÂÒÂë¡£Êä³öSQLÖ´ÐеÄ×Ö·û´®£¬ÀýÈ磺insert into table values('1','²Ë²Ë','23','ÄÐ'); Õâʱºò¿ÉÒÔ¿´µ½ÏÔʾµÄ¶¼ÊÇÖÐÎÄ£¬µ«Êǵ±Äã´ò¿ªÊý¾Ý¿â²é¿´¼Ç¼µÄʱºò¿´µ½»¹ÊÇÂÒÂ룬ÔΣ¡ÎªÊ²Ã´£¿Èç¹ûÕâʱºòÄã´ÓMYSQL¿ØÖÆ̨ÃüÁîÐÐÏÂÊäÈëÉÏÃæµÄÓï¾äÖ´ÐÐʱ£¬Ôٲ鿴Êý¾Ý¿â¼Ç¼£¬ß×£¡Ã»ÓÐÎÊÌâѽ£¬Ö´ÐÐͬÑùµÄÓï¾ä£¬ÎªÊ²Ã´µÃµ½²»Ò»ÑùµÄ½á¹ûÄØ£¿¿´À´JDBCÊÇÄÑÍÑÆä¾ÌÁË¡£
¼ò¶øÑÔÖ®½â¾ö·½·¨£º
Á¬½ÓÊý¾Ý¿âʱ£ºjdbc:mysql:3306//localhost/test?user=root&password=&useUnicode=true&characterEncoding=ISO-8859-1"£¬Ö¸Ã÷±àÂëΪISO-8859-1£¬ÎÒ¿´ÁËÒ»ÏÂMYSQLµÄÏà¹ØÎļþ£¬ËüĬÈϵıàÂë¾ÍÊÇISO-8859-1£¬µ«ÊÇÔÚÕâÀï²»Ö¸Ã÷µÄ»°»¹ÊÇÓÐÎÊÌ⣬ÖÐÎÄÈԾɲ»ÄÜÕý³£ÏÔʾ(µ½µ×ΪʲôÆäʵÎÒÒ²²»ÊǺÜÇå³þ)¡£ÕâÑùÔÚÍùÊý¾Ý¿âÖдæ·ÅµÄʱºò¾ÍÕý³£ÁË¡£
´ÓÊý¾Ý¿âÖжÁÈ¡Êý¾Ýʱ£¬Èç¹ûÓÃrs.getString("name")µÄ»°£¬ÂÒÂëÓÖ³öÀ´ÁË£¬Õ⻹ÊÇÒ»¸ö±àÂëת»»µÄÎÊÌ⣬ÏÂÃæ¸øÒ»¸öת»»º¯Êý£º
<%
/********************************************
º¯ÊýÃû£ºtoGB
×÷ Ó㺽«ISO8859×Ö·û¼¯×ª»»ÎªGB2312×Ö·û¼¯
½â¾öÊý¾Ý¿âÖÐÎÄÏÔʾÎÊÌâ
²Î Êý£ºiso ----Ҫת»»µÄ×Ö·û´®
·µ»ØÖµ£º gb ----ת»»ºóµÄ×Ö·û´®
********************************************/
%>
<%! public String toGB(String iso)
{
String gb=null;
if (iso != null) {
try {
gb=new String(iso.getBytes("ISO-8859-1"),"GB2312");
} catch (Exception e) {
gb=null;
}
}
return gb;
}
%>
´ÓÊý¾Ý¿âÖжÁÈ¡Êý¾ÝʱtoGB(rs.getString("name"),ÄÇôÊý¾Ý¿âÖеÄÖÐÎľͻáÕý³£ÏÔʾÁË¡£
Ïà¹ØÎĵµ£º
MySQL£ºÈÕÆÚº¯Êý¡¢Ê±¼äº¯Êý×ܽᣨMySQL 5.X£©
²Î¿¼³¤ÎÄ£º
Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
1.1 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºnow()
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
³ýÁË now() º¯ÊýÄÜ»ñµÃµ±Ç°µ ......
InnoDB
ºÍMyISAM
ÊÇÔÚʹÓÃMySQL
×î³£ÓõÄÁ½¸ö±íÀàÐÍ£¬¸÷ÓÐÓÅȱµã£¬ÊÓ¾ßÌåÓ¦Óöø¶¨¡£»ù±¾µÄ²î±ðΪ£ºMyISAM
ÀàÐͲ»Ö§³ÖÊÂÎñ´¦ÀíµÈ¸ß¼¶´¦Àí£¬¶øInnoDB
ÀàÐÍÖ§³Ö¡£MyISAM
ÀàÐ͵ıíÇ¿µ÷µÄÊÇÐÔÄÜ£¬ÆäÖ´ÐÐÊý¶È±ÈInnoDB
ÀàÐ͸ü¿ì£¬µ«ÊDz»ÌṩÊÂÎñÖ§³Ö£¬¶øInnoDB
ÌṩÊÂÎñÖ§³ÖÒѾÍⲿ¼üµÈ¸ß¼¶Êý¾Ý¿â¹¦ÄÜ¡£
MyIASMÊÇIASM± ......
×î½ü¼¸ÌìÏÐÀ´ÎÞÊ£¬±ã³¢ÊÔÁËÒ»ÏÂÓÃC²Ù×÷Êý¾Ý¿â£¬ÏÂÃæ±ãÊÇÎÒ²âÊԵľßÌå½á¹û£º
¿ª·¢»·¾³ÊÇwindows 7 ultimate(Ó¢ÎÄ°æ) IDE ÊÇvs 2008 professional ÖÐÎÄ°æ,Êý¾Ý¿âÊÇmysql 5.1
Ê×ÏÈ£¬ÎÒÔÚMySQL¿âÖд´½¨ÁËÒ»¸ötest±í£º
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT ......
Õ⼸Ìì×öÒ»¸ö²éѯ£¬ÐèÒªÔÚÒ»¸öÖ¸¶¨µÄ½á¹û¼¯ÖнøÐвéѯ£¬ÀýÈ磺
select * from table_name where doc_id IN ('1dba', 'c20a', '907b')
ÆäÖÐIN×Ó¾äÖеÄdoc_idÁбíÊÇͨ¹ýµ÷ÓÃÒ»¸öÍⲿ½Ó¿Ú»ñµÃÒ»×édoc_id³£Á¿ÁÐ±í£¬È»ºóÔÚ±¾µØ¿âÖÐËÑË÷·ûºÏÕâ¸öÁбíµÄÊý¾Ý
¼Ç¼¡£ºóÀ´·¢ÏÖmysql·µ»ØµÄ½á¹û¼¯µÄÅÅÐòÊÇ°´ÕÕÈë¿â˳Ðò¸ø³öµÄ£¬µ«ÊÇÎÒ ......