How to set useUnicode=true and characterEncoding=utf8 properties on Spring-managed MySQL JDBC connection

后端 未结 5 656
醉话见心
醉话见心 2021-02-05 06:27

I\'m currently building a Spring MVC webapp and the database is the vital backend part. For whatever reason, however, Spring is refusing to process the data as UTF-8. Since the

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-05 06:46

    The problem may be caused by specifying utf8 and not UTF-8. From Using Character Sets and Unicode:

    When specifying character encodings on the client side, use Java-style names. The following table lists MySQL character set names and the corresponding Java-style names...

    and utf8 maps to UTF-8. Try the following JDBC URL:

    jdbc:mysql://localhost:3306/?useUnicode=yes&characterEncoding=UTF-8

提交回复
热议问题