从Hibernate到MySql的连接字符集是什么?

时间:2015-03-31 12:31:21

标签: java mysql hibernate

我使用Jpa / Hibernate库从Java连接MySQL DB。 MySQL文档说“如果不使用默认值,则必须更改每个服务器连接的字符设置”。

我如何知道底层连接使用哪个Charset以及如何更改?

谢谢

1 个答案:

答案 0 :(得分:0)

使用characterEncodingCharSet属性更改hibernate使用的字符集。

示例:将charset设置为utf-8:

<property name="hibernate.connection.CharSet">utf8</property>
<property name="hibernate.connection.characterEncoding">utf8</property>
<property name="hibernate.connection.useUnicode">true</property>