4

I'm trying to set my tables Character Set to UTF-8 instead of latin1. I was trying to do it by adding:

spring.jpa.properties.hibernate.connection.CharSet=UTF-8
spring.jpa.properties.hibernate.connection.characterEncoding=UTF-8
spring.jpa.properties.hibernate.connection.useUnicode=true

to the application.properties file. I also tried to do it through the connection URL by adding:

&useUnicode=true&connectionCollation=utf8_general_ci&characterSetResults=utf8

to the end of the URL. None of them worked. I am using spring boot version 2.0.1.RELEASE and hibernate.

  • 4
    try this `?useUnicode=yes&characterEncoding=UTF-8` at the end of your database url ( **example** : `jdbc:mysql://localhost:3306/dbName?useUnicode=yes&characterEncoding=UTF-8` ) – Abdelghani Roussi May 28 '18 at 13:32
  • Thank you, it is working now. I added exactly what you said to the end of my database url. – Alexandre Maia May 28 '18 at 13:47
  • I am using jhipster with Mysql with your suggested url but tables are always created with 'latin1_swedish_ci' and i need to modify it manually to 'UTf-8'. The url in jhipster config is : 'url: jdbc:mysql://localhost:3306/epicerie?useUnicode=true&characterEncoding=UTF-8' – Farouk Apr 26 '19 at 23:10
  • Depending on connection pool: eg for Tomcat: `spring.datasource.tomcat.connection-properties=useUnicode=true;characterEncoding=UTF-8` as documented in https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#data-properties – Ivar Nov 15 '19 at 15:40

0 Answers0