[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - JBoss + MySQL + Persistence encoding issues

adam.bonkowski do-not-reply at jboss.com
Thu Dec 13 02:51:30 EST 2007

I'm using JBoss 4.2.1 with MySQL 5.0.48. The app I develop is an EJB3 with Java Persistence app. I'd like to store text data in UTF-8. 
I added "&useUnicode=true&characterEncoding=UTF" to the connection url in my xa-datasource. I also set 

in persistence.xml
The default character set of the MySQL database and all its tables is utf8.

However there are some problems:
1. When I send some data from a web form with utf8 set in meta everything is stored correctly in the database.
2. When I hardcode strings in Java and invoke some methods putting data, the text in database is encoded in ISO 8859-2 aka latin2 even though the sources are in utf8 (ISO 8859-2 is the encoding of my system which is CentOS 5).
3. When I try to transfer from one database (Oracle with ISO 8859-2) to another (mentioned MySQL) the data is also stored in ISO 8859-2. 

Why isn't the conversion done?
This happens even though i set the env variable $LANG to pl_PL.UTF-8.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112462#4112462

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112462

More information about the jboss-user mailing list