-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: hibernate- mysql - linux- unicode problem
PostPosted: Sun Jan 18, 2009 4:11 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
hiii
first our DB server was on windows and we are working on a web application and we had this problem:
when arabic text is entered an exception came out :
Incorrect string value: '\xD8\xAA\xD8\xAA\xD8\xAA...' for column 'TEXT_AT' at row 1
and the text value is not saved in DB..
then we put :
(1) <property name="hibernate.connection.useUnicode">true</property>
(2) <property name="hibernate.connection.characterEncoding">UTF-8</property>
in the hibernate configuration file and the problem was solved .
But when we moved DB server to Linux the problem came out again !!!!!!
Now although we put the 2 lines (1) and (2) in the hibernate configuration file but the the tables are created with a Character set : cp 1252 West Europeon for varchar data type

Can u help me plz??


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 4:36 am 
Newbie

Joined: Sat Jan 17, 2009 5:13 am
Posts: 6
Hi!
I'm also using 3rd configuration line:
(3) <property name="hibernate.connection.charSet">UTF-8</property>

Please provide info which database you are using (exact version), your "hibernate.dialect" setting and "hibernate.hbm2ddl.auto" setting.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 4:50 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
database : mysql 5.0
hibernate.dialect : org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.hbm2ddl.auto : create


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 4:58 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
by the way i added the third line but it didn't work


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 4:59 am 
Newbie

Joined: Sat Jan 17, 2009 5:13 am
Posts: 6
As far as i remember adding 3rd config is enough (i have almost same configuration except that i'm using Mac OS X instead of linux - but they are both *nix systems)
hibernate.connection.charSet = UTF-8 should force DB tables creation using UTF-8 encoding, so you should manually drop you tables if they are created with different encoding.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 4:59 am 
Newbie

Joined: Sat Jan 17, 2009 5:13 am
Posts: 6
h3a wrote:
by the way i added the third line but it didn't work

Did you recreated DB tables?
Check which encoding they are using.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 5:06 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
yes i recreated th DB and they are still using: cp 1252 West Europeon

it's driving me crazy


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 5:12 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
i think :
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">UTF-8</property>
<property name="hibernate.connection.charSet">UTF-8</property>

are used for the connection only but not to create DB tables that uses utf-8 ....


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 5:17 am 
Newbie

Joined: Sat Jan 17, 2009 5:13 am
Posts: 6
h3a wrote:
i think :
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">UTF-8</property>
<property name="hibernate.connection.charSet">UTF-8</property>

are used for the connection only but not to create DB tables that uses utf-8 ....

One more thing i'd recommend you to try is to completely drop your DB schema (backup important data before :) ) and create it with following command

Code:
create database schema_name default character set = "UTF8" default collate = "utf8_general_ci"
replacing schema_name with your schema name


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 5:51 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
thanks a lot it worked :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.