I am dealing with a Brazilian customer where the data is in Portuguese language.
My application is responsible to read the data through web-service calls and store it in our database. The issue that I am currently facing is the Portuguese characters are not getting identified as it is and is stored in my database as a special character.
I am using MySQL database with all tables configured as collation UTF-8. I tried manually inserting Portuguese character into my database and it worked. So I am suspecting its java who is converting the Portuguese characters into special character.
Also, my application is using Hibernate for database operations.
I am able to get the character as I see in logs and the issue reside while trying to store that data in database.
Eg: Original characters: Gerãt
Database characters: Gerãt
What configurations or setting or changes I need to do to my database so that I can capture the data in Portuguese language as it is?
It may not be database issue, but an application configuration issue.
Few pointers to help :
Hope it helps.
Try changing your hibernate configuration to:
<hibernate-configuration>
<session-factory>
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">UTF-8</property>
<property name="connection.charSet">UTF-8</property>
If that doesn't work, try adding UTF-8
to your characterEncoding
in your JDBC url.
Also, this question might help you: Cannot insert non latin symbols in MySQL
This worked in my case:
Add environment variable JAVA_TOOL_OPTIONS instead of _JAVA_OPTIONS with value as
-Dfile.encoding=UTF8
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.