我使用Jpa / Hibernate库从Java连接MySQL DB。 MySQL文档说“如果不使用默认值,则必须更改每个服务器连接的字符设置”。
我如何知道底层连接使用哪个Charset以及如何更改?
谢谢
答案 0 :(得分:0)
使用characterEncoding
和CharSet
属性更改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>