Hibernate MySQL ÖÐÎÄÂÒÂëÎÊÌâ
Hibernate MySQL ÖÐÎÄÂÒÂëÎÊÌâ
»·¾³£ºHibernate 2.1.7 + MySQL4.1£¨MySQLµÄ±àÂëÒÑÉèÖÃΪutf8£©
ÎÊÌ⣺ͨ¹ýHibernateÏòMySQLдÈëÖÐÎĺó£¬Í¨¹ýHibernateÈ¡»ØÊý¾Ý£¬ÔÚconsoleÖдòÓ¡java¶ÔÏóÏÔʾÕý³£¡£µ«ÔÚMySQL Query BrowserÖп´µ½µÄÊÇÂÒÂ룬´«¸øÇ°¶ËµÄFlexÒ²ÊÇÂÒÂë¡£
ÔÒò£ºHibernateµÄ»ù´¡»¹ÊÇJDBC£¬ËùÒÔÒ»ÑùÐèÒªÉèÖÃcharacterEncoding£¡
½â¾ö·½·¨£º
ÔÚhibernate.cfg.xmlÖÐÓ¦¸ÃÕâÑùд
<property name="connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8</property>
Èç¹ûÓÃhibernate.properties
#hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
ps£º´¦ÀíÖÐÎĵĻ°£¬characterEncodingÓÃGBKÒ»Ñù¿ÉÒÔ¡£
µ«×Ö½Ú±àÂëÎÊÌâ×îºÃµÄ½â¾ö·½·¨»¹ÊÇͳһʹÓÃUTF-8£¡£¡£¡
posted on 2005-06-10 21:35 °åÇÅ¾Ó ÔĶÁ(140) ÆÀÂÛ(0) ±à¼ ÊÕ²Ø
ÁíÍâÒ»¸öblog»¹ÓÐÏêϸµÄÈýÖÖ½â¾ö·½·¨£ºhttp://www.cnblogs.com/josson/
Hibernate+mysql ÖÐÎÄÎÊÌâ½â¾ö·½°¸.
1, mysql°²×°Ê±ÉèÖÃ×Ö·û¼¯utf-8, jdbcÇý¶¯3.0.15ÒÔÉÏ.
2. hibernateÅäÖÃÎļþÖÐ,¼ÓÉÏÊôÐÔ
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">UTF-8</property>
3. web.xmlÉèÖÃFilter
=================================================
<filter>
<filter-name>
Set Web Application Character Encoding
</filter-name>
<filter-class>cn.com.commnet.util.SetEncodeFilter</filter-class>
<init-param>
<param-name>defaultencoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>
Set Web Application Character Encoding
</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
=================
Ïà¹ØÎĵµ£º
MYSQL×ÔÔöÁÐ
1.¹Ø¼ü×Ö £ºauto_increment
2.×ÔÔöÓ÷¨
Àý:
CREATE TABLE animals ( id mediumint not null auto_increment,
name char(30) not null,
primary key (id));
3.¹ØÓÚ×ÔÔö
Q:Ôõô»ñµÃµ±Ç°µÄ×ÔÔöµÄ×î´óÖµ?
A:select @@identity
Q:Ôõô»ñµÃtableµÄµ±Ç°×ÔÔö×î´óÖµ?
A:select max(id) from table ......
ÒÔÏÂÃüÁî¿ÉÒÔÔÚÈκÎÒѾÁ¬½ÓÉÏMYSQL·þÎñÆ÷µÄ¿Í»§¶ËÉÏÖ´ÐС£
show full processlist ;
kill 57725;#ɱµôÉÏÃæ²éµ½µÄij¸öµ¼ÖÂ×èÈûµÄÁ¬½Ó
SELECT @@profiling;
SET profiling = 1;
SHOW PROFILES;
SHOW PROFILE for QUERY 1;
#ϵͳÉèÖÃ
show variables like '%key%';
show variables like '%key%';
show variables l ......
×î½üÏëÔÚ·þÎñÆ÷ÉÏÊÔÊÔMySQL5.1µÄ·ÖÇø£¬ÓÚÊǾÍÏë×Å×°¸öMySQL5.1£¬¾¹ýÍ´¿àµÄÒ»¶Î¾Àúºó£¬ÖÕÓÚÕÒ¸öÏÂÃæ×°¸öºÜºÃµÄ½Ì³Ì£¬ÌûÉÏÀ´±¸Íü¡£
1¡¢MySQLÃâ°²×°°æ/¶þ½øÖÆ°æÈí¼þ£¬²»ÓñàÒ룬ÏÂÔصØÖ·£º
http://dev.mysql.com/downloads/
Îļþ¸ñʽ£ºMYSQL-VERSION-OS.tar.gz
2¡¢´ ......