-->
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.  [ 6 posts ] 
Author Message
 Post subject: mysql, unicode strings
PostPosted: Sat Oct 08, 2005 1:57 pm 
Newbie

Joined: Sat Oct 08, 2005 1:23 pm
Posts: 3
Problem:

I use Mysql 4.whatever with UTF8 set as default encoding.
Hibernate's <property name="connection.url">:
jdbc:mysql://localhost:3306/dictionary?useUnicode=true&amp;characterEncoding=UTF-8&amp;useOldUTF8Behavior=true

Have an object
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">

   <class name="lv.lu.mii.luweb2005.dictionary.domain.Text" discriminator-value="false" table="TEXT">
       <id name="id" column="TEXT_ID">
         <generator class="increment" />
      </id>

      <property name="urlOrigin" />
      <property name="content" type="text"/>      
      <property name="added" type="timestamp" />
      <property name="priv" type="boolean" />
   </class>

</hibernate-mapping>


I save
with
Code:
      Session session = HibernateUtil.currentSession();
      Transaction tx = session.beginTransaction();
      session.save(newText);
      tx.commit();
      HibernateUtil.closeSession();


PROBLEM. If content is a string with unicode characters then the resulting string in mysql is chopped at the end by one for each unicode character.

So - i believe somewhere is a place which estimates the length of the string in unicode chars and tries to save it in real bytes to mySQL. As a unicode char == 2 bytes, we get lost.

Does anyone have any idea, what could be wrong?
I am completely new to Java, Hibernate and Mysql, so it could easily be some misconfiguration..


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 2:11 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
try changing the mysql driver around a little


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 2:21 pm 
Newbie

Joined: Sat Oct 08, 2005 1:23 pm
Posts: 3
Do you mean the mysql connector?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 2:38 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
I'm sure there is a jar file somewhere, containing the classes your application needs to make a database connection to mysql.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 2:46 pm 
Newbie

Joined: Sat Oct 08, 2005 1:23 pm
Posts: 3
Thanks. I took mysql 3.2 alfa connector and now it works. It gets and receives from the d-base, but somehow I do not see the lines from mysql prompt. It does not however matter now... :). THanks, again.


Top
 Profile  
 
 Post subject: MySQL driver problem
PostPosted: Wed Nov 02, 2005 11:04 am 
Newbie

Joined: Wed Nov 02, 2005 11:00 am
Posts: 12
Location: Austria, Vienna
Hi,

Thanks for the hint!

It actually is a driver problem. I was using 3.1.10 and faced the same problem. Now I'm using 3.1.11 and the problem is gone. 3.2.0 also solves the problem but the driver is an alpha version so I don't want to used it.

RĂ¼diger Engelberger


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