-->
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.  [ 5 posts ] 
Author Message
 Post subject: Characters encoding problem.
PostPosted: Wed Sep 29, 2004 4:26 am 
Newbie

Joined: Tue May 25, 2004 3:22 pm
Posts: 18
Hi there.

I have developed a CMS system that is supposed to support something about 8 european countries (i.e. languages) and it's going for the production very soon, but I have encountered a problem with storing russian text into mySQL database.

Actually the production system has a AS400 backend and since I don't have mainframe locally I used mySQL for testing purpose (so far that worked :) and I don't know what would be the behaviour in the real system if I try to use it with languages other then english (because the production system has a real database that I must not play with).
So, to be sure everything would be OK I tried rueeian localization and it turned out that the original russian text is stored as "??????????????" into the DB (mySQL).

I made sure that right before the insert/update the right text is stored into my business objects and after the update it is screwed...

I guess Hibernate has little (or nothing at all) to do with that, and I need to tell mySQL (and AS400 DB/2 on the production) what character set (encoding) to use..

Any help woul be appreciated.

P.S. Is there a way to see what values are exactly being inserted into DB, because with "showSQL=true" I can only see something like this in the log:

Hibernate: insert into GWER00 (ERSDESCR, ERLDESCR, ERNAME, EROFID, ERENTITYID, ERINDEX, ERTYPE, ERID) values (?, ?, ?, ?, ?, ?, 'TXT', ?)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 29, 2004 8:15 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 8:40 pm
Posts: 30
Location: SF Bay Area
You ask :

Is there a way to see what values are exactly being inserted into DB, because with "showSQL=true" I can only see something like this in the log:

Before attempting to save it you could write it to a log file.

Are you using use-in-to-string in your hbm files - like :

<property name="name" type="string">
<meta attribute="use-in-tostring">true</meta>
<column name="NAME" not-null="true" unique="true" index="EMM_ARTIST_NAME"/>
</property>

Also, if you are building a web app - your web container
might require an explicit reference to the character set.
That is, it might not use UTF-8 by default.

If you don't find anything on that try putting the following
line at the top of all your jsps.

<%@ page contentType="text/html; charset=UTF-8" %>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 30, 2004 4:13 am 
Newbie

Joined: Tue May 25, 2004 3:22 pm
Posts: 18
Of course I do explicitly force UTF-8 encodnig in all my JSPs like you described.. As I said - I made sure that the CORRECT value is being set to the appropriate BO member right before inserting/updating it into database...

But thatnks for the <meta attribute="use-in-tostring">true</meta>

suggestion, though I'm pretty sure if that works - I'm gonna see correct values before insert. I guess I just have to tell the DB explicitly what encoding to use, but I don't have an idea how to do that (maybe in connection string parameter?)...More suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 6:38 am 
Newbie

Joined: Wed Sep 10, 2003 3:12 am
Posts: 4
Location: Bergen, Norway
I am encountering the same problem as dime describes.

I've just tried the meta tag without any change in results.

I'm reading texts from a regular text file and putting them into a String property.

The problem seems to only occur with these chars:
-
'
"

When the text is saved to the DB via hibernate all those chars are saved as "?" Logging output of the String property before it is inserted into the db shows the correct text just as it is read from the textfile, but once it's saved to my MySQL db its changed to "?"

I've also been fiddling about with these config settings:
<property name="hibernate.connnection.charSet">ISO8859_1</property>
<property name="hibernate.connnection.character_set_connection">latin1</property>
<property name="hibernate.connnection.character_set_client">latin1</property>
<property name="hibernate.connnection.character_set_results">latin1</property>

Though I have not been able to fix this problem as of yet. I've also tried UTF8 in the hibernate.connection.charSet property.

Anybody got some new info as to how to fix this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:00 am 
Newbie

Joined: Wed Sep 10, 2003 3:12 am
Posts: 4
Location: Bergen, Norway
I've also now tried this property setting in my hibernate config:
<property name="hibernate.connection.lc_type">ISO8859_1</property>

And UTF8, still no change though


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.