Robert Vangor
Robert Vangor

Reputation: 1068

Spring Data JPA - Encoding UTF-8 doesn't work

When I'm doing

repository.save(entity)

characters like "č","š", ... will be displayed as "?". I'm able to display the data right before that line of code and it is formated normally. Also insert through terminal works fine.

Tried many things like :

spring.datasource.url= jdbc:mysql://localhost:3306/database?useUnicode=yes&characterEncoding=UTF-8
connection.useUnicode=true
connection.characterEncoding=utf-8
hibernate.connection.useUnicode=true
hibernate.connection.characterEncoding=UTF-8
spring.datasource.sqlScriptEncoding=UTF-8

spring.thymeleaf.encoding=UTF-8
spring.mvc.formcontent.putfilter.enabled=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true

and non of them work. I'm using Spring Boot 2.0.0M2 and also Spring Security.

Upvotes: 0

Views: 3485

Answers (1)

Shibashis
Shibashis

Reputation: 8401

& should not be added to the connection string. Spring ensures the url is encoded when the actual connection is made.

Also the correct param to be set when the connection is made is useUnicode=true

Upvotes: 1

Related Questions