This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate + MySQL Encoding" Watch "Hibernate + MySQL Encoding" New topic

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.

Stan Sokolov
Ranch Hand

Joined: Apr 13, 2004
Posts: 120

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

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:

Thanks every one!
I agree. Here's the link:
subject: Hibernate + MySQL Encoding
jQuery in Action, 3rd edition