If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Unicode in MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-18-04, 09:26
webgard webgard is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
Unicode in MySQL

Hi guys and gals

I want to enter unicode data to MySQL. I wrote a jsp for data gathering from user. but after entering data and clicking Submit button, the data which enter to MySQL are unicode numbers. for example I enter a 4-letter word in Arabic and after clicking on submit button, the "& #1587; & #1604; & #1575; & #1605;" goes to MySQL. (I put blanks inside them for readability) What is the problem? My jsp charset is utf8. What are possiblities?

I have mysql-4.1.1a-alpha-win with mysql-connector-java-3.0.10-stable and Tomcat 4.1.24 and also this parameter in server.xml of Tomcat, so Tomcat should connect to MySQL with UTF-8. Right? Is '& amp;' in parameter correct?

<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/test?userUnicode=true&amp;characterEncoding=UTF-8</value>
</parameter>

Also my Browser (IE) encoding is UTF8.


Thanks,
Webgard

Last edited by webgard; 02-18-04 at 09:35.
Reply With Quote
  #2 (permalink)  
Old 02-19-04, 04:54
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
hi,my problem is the same as yours.

i think string's encoding should be convert before insert date into the mysql.
how do you check the data in mysql?what tools?
Reply With Quote
  #3 (permalink)  
Old 02-19-04, 06:04
webgard webgard is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
Hi,

I use "Jbuilder Database Pilot" for checking data. What do u use?

I will work on it more after holidays. I will let you know the result if I succeed and Please do the same in the case you reach some points.

Now I have several ideas, I should test them.

I will start server with utf8, make a clean db with utf8, and tables with utf8 and also connect using utf8, with jsp encoding utf8 and IE is utf8 too. :-) all utf8

I will test it.

Keep in touch
Webgard
Reply With Quote
  #4 (permalink)  
Old 02-19-04, 12:19
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
hi

i have test your case.
it can't be see that string is chinese.it just is something like ???????;

the jdbc driver maybe can't corresponding the mysql4.1.1
maybe it isn't stable one.it just is my options.

the sql is different from the older.
you can look the following url:

http://perlwelt.horus.at/Beispiele/M...lUnicodeMysql/
Reply With Quote
  #5 (permalink)  
Old 02-20-04, 13:45
webgard webgard is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
zhu1230,

just a note:

When you are using JDBC drivers to connect MySQL, you should use 'UTF-8' instead of 'utf8', becasue Java can't understand utf8.

useUnicode=true&characterEncoding=UTF-8 is correct.

Seeing just ?????? was my first problem. I just changed utf8 to UTF-8 and it worked. seeing unicode numbers instead of unicode charactes is my second problem.

Regards,
Webgard
Reply With Quote
  #6 (permalink)  
Old 02-21-04, 10:28
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
i am very glad to see your answer!

the mistake make me almost crazy!

i will continue test this.thank you.

regards
zhu1230
Reply With Quote
  #7 (permalink)  
Old 02-21-04, 11:29
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
great!
i have test the case.
i have get the correct string.

it is all UNICODE.

and i have found a "bug" in the connect pool configuration which the tomcat-dos indicate.
the following snip code is no effect about the characterEncoding,i use it with the struts.i have waste much time to test the problem with the "bug" code.



<Resource name="jdbc/zzksDB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/zzksDB">
<parameter>
<name>username</name>
<value>dbusername</value>
</parameter>
<parameter>
<name>password</name>
<value>dbpassword</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/zzks</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>200</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>200113</value>
</parameter>
<parameter>
<name>useUnicode</name>
<value>true</value>
</parameter>
<parameter>
<name>characterEncoding</name>
<value>UTF-8</value>
</parameter>
</ResourceParams>

if i use the url with


<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/zzks?useUnicode=true&characterEncoding=UTF-8</value>
</parameter>


then the tomcat can't start.

my tomcat is 5.0.jdk 1.4.2 win2000(chinese)
mysql 4.1.1


regards
zhu1230
Reply With Quote
  #8 (permalink)  
Old 02-21-04, 11:41
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
about your problem,i have some suggestions:

1,use the filter which can change the request's characterEncoding.
If you want,i can give some code.

2,don't use the server.xml connect pool,you can test to use the JSP to connect the database first.if right, we can test other effect conn-pool;

3,change the jvm-character-encoding to UTF-8.(i don't know whether this is necessary.i can test the necessary of it.but i want that all is unicode.)

this is all.

regards
zhu1230
Reply With Quote
  #9 (permalink)  
Old 02-21-04, 13:18
webgard webgard is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
hi

you said:

-------------
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/zzks?useUnicode=true&characterEncoding=UTF-8<

/value>
</parameter>

then the tomcat can't start.
------

did you use '&' in XML? it can't be understood by parser. try to change '&' to '& amp;' (without blank) and restart Tomcat and let me know the result.

I will test your case and let you know the result..

Regards,
webgard
Reply With Quote
  #10 (permalink)  
Old 02-22-04, 00:37
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
oh,i see.i forget it.

ALL is OK!

i don't know why the following snip code has no effect?

<parameter>
<name>useUnicode</name>
<value>true</value>
</parameter>
<parameter>
<name>characterEncoding</name>
<value>UTF-8</value>
</parameter>


although this condition,i have get my purpose.
Reply With Quote
  #11 (permalink)  
Old 02-22-04, 00:39
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
i hope the mysql4.1 have the stable version.

regards
zhu1230
Reply With Quote
  #12 (permalink)  
Old 02-22-04, 10:32
webgard webgard is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
Hi,

you said it worked on your box!! Now, you see unicode chars in database?? u dont see unicode numbers instead of chracters in your DB??

I am still seeing the unicode numbers instead of unicode chars. Maybe my tool (Jbuilder Pilot) has problem. What tools are u using as browsing the database?

regards,
Webgard
Reply With Quote
  #13 (permalink)  
Old 02-23-04, 03:43
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
i input the string to db,and get the same string from db.
then,i use the phpmyadmin to get the correct string.not numbers.


you have set all is UTF-8?

can you ensure?

i am very glad to help you,i wait for your success!


regards
zhu1230
Reply With Quote
  #14 (permalink)  
Old 02-23-04, 07:45
webgard webgard is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
zhu1230

yeah, i can save and retrieve unicode chars. but when I see inside the DB with database Pilot, or MySQL Control Center. I see unicode numbers.

Mmmm... I think I have no problem. Maybe Pilot and Control Center are doing the right job and i SHOULD see unicode numbers instead of uniode chars.

BTW, thanks for your patience. I will dig more.

Regards,
Peyman
Reply With Quote
  #15 (permalink)  
Old 02-23-04, 09:44
zhu1230 zhu1230 is offline
Registered User
 
Join Date: Feb 2004
Posts: 12
yeah,i agree with you.
can you tell me your ICQ oR msn?
i havn't the friend about the discuss of characterencoding problem.
if we encounter one new problem,we can talk together again.



regards
zhu1230
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On