my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes Hibernate + MySQL Encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate + MySQL Encoding" Watch "Hibernate + MySQL Encoding" New topic
Author

Hibernate + MySQL Encoding

Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
Hey Folks,

I'm having trouble with charset encoding in a application that uses Hibernate and MySQL... When I update (through the site) a registry with a local char (like an accent for example) the record in the database gets wrong, with mixed chars...

I've executed manualy the update query in the MySQL Query Browser and the charset looks just great... So, I think the problem is on the Hibernate configuration or in some point of the mysql connection. Can anybody help me?

Thanks in advance.


SCJP, SCWCD
Stas Sokolov
Ranch Hand

Joined: Apr 13, 2004
Posts: 117

You have to check connection string that you use. For russian char-set I am using



Good luck for yourself.
Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
I've tried to use this in the hibernate.cfg.xml



Then in the logs I get this:

INFO - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/star
INFO - connection properties: {user=root, password=****, charSet=ISO8859_1}

But the problem remains...

The strange is that when I load the page the data is OK, with the accent (from a manually update), but after doing an update in the page the registry get messed.
Wagner Danda Da Silva Filho
Ranch Hand

Joined: Mar 21, 2003
Posts: 80
Hey,

after debugging the app I found the error was when getting the values from the JSP page! I solved it just changing the page directive. Refeer to this link for more details:

http://www.coderanch.com/t/52345/Struts/Encoding

Thanks every one!
 
Consider Paul's rocket mass heater.
 
subject: Hibernate + MySQL Encoding
 
Similar Threads
Calling Stored proc using Hibernate @NamedNativeQuery
native SQL update in Hibernate
Cant insert euro symbol
Error from MySql
Problem fetching request parameter