栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Hibernate + MySQL:如何设置数据库和表的编码utf-8

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Hibernate + MySQL:如何设置数据库和表的编码utf-8

您还可以使用编码创建数据库。
只需

phpMyAdmin
用于数据库/表创建。

您可以在hibernate设置的URL中指定一些URL参数,以使用UTF8建立连接:

<!-- Database Settings --><property name="connection.driver_class">com.mysql.jdbc.Driver</property><!--  for performance reasons changed to MyISAM from org.hibernate.dialect.MySQLInnoDBDialect --><property name="dialect">org.openmeetings.app.hibernate.utils.MySQL5MyISAMDialect</property><property name="connection.url">jdbc:mysql://localhost/openmeetings?autoReconnect=true&amp;useUnipre=true&amp;createDatabaseIfNotExist=true&amp;characterEncoding=utf-8</property><property name="hibernate.connection.CharSet">utf8</property><property name="hibernate.connection.characterEncoding">utf8</property><property name="hibernate.connection.useUnipre">true</property>

您无需将数据库中的整个编码设置为utf8,仅当您使用

<!-- Database Scheme Auto Update --><property name="hbm2ddl.auto">update</property>

您将必须将MySQL的默认编码设置为utf8。因为

hbm2dll
将会使用数据库的默认编码。

您可能仍会使用

hbm2ddl.auto
,并手动修改数据库的表以具有utf8排序规则。

如果您没有使用

hbm2ddl.auto
,则可以使用您喜欢的编码来简单地创建表。无需将数据库设置为特殊编码。

塞巴斯蒂安



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/412393.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号