hi mark,
> However, once you start displaying things on the console, all bets are > off...because your console needs to understand UTF-8 as well, so using > the 'eyeball' method of testing won't work too well here. in principle i agree with you. but only having java tests is simply not enough. i have to take into consideration that multiple clients may access the db. be it via the console or gui clients or what ever. so i have to make sure that every client is in sync.
i have done now quite some extensive testing with various clients:
- JFaceDBC (an eclipse plugin) i used it for writing the data into the db and reading from it. - the (mysql) console (read only) - mysql-command-center 0.94 (read only) - a java programm that reads from the database via a ResultSet. the reading is done once via getString and once via getBytes.
i have defined two connection that i use for writing (exclusively thru JFaceDBC) and reading.
NONE = jdbc:mysql://localhost/?autoReconnect=true UTF8 = as_above + &useUnicode=true&characterEncoding=UTF-8
A) write by NONE
1) read by NONE (JFACE)
K??sel;B?;
g?l;?lb?rt;
???????????;???????????; 2) read by UTF8 (JFACE)
K��sel;B�b;
�g�l;�lb�rt;
???????????;???????????; 3) read by UTF8 (mysql-CONSOLE)
| K��sel | B�b |
| �g�l | �lb�rt |
| ??????????? | ??????????? | 4) read by UTF8 (mysql-cc 0.9.4)
the same result as 3) 5) read by NONE (java getBytes)
[java] K?sel - B?
[java] ?l - ?b?t
[java] ??????????? - ???????????6) read by NONE (java getString)
[java] K??sel - B?
[java] ?g?l - ?lb?rt
[java] ??????????? - ??????????? 7) read by UTF (java getBytes)
[java] K��sel - B�b
[java] �g�l - �lb�rt
[java] ??????????? - ??????????? 8) read by UTF (java getString)
[java] K?sel - B?
[java] ?l - ?b?t
[java] ??????????? - ???????????B) write by UTF8
1) read by NONE (JFACE)
K??sel;B?;
? g?l;?lb?rt;
???????????;???????????; 2) read by UTF8 (JFACE)
K��sel;B�b;
�g�l;�lb�rt;
???????????;???????????; 3) read by UTF8 (mysql-CONSOLE)
| K��sel | B�b |
| �g�l | �lb�rt |
| ??????????? | ??????????? | 4) read by UTF8 (mysql-cc 0.9.4)
the same result as 3) 5) read by NONE (java getBytes)
[java] K??sel - B?
[java] ?g?l - ?lb?rt
[java] ??????????? - ??????????? 6) read by NONE (java getString)
[java] K??sel - B?
[java] ?g?l - ?lb?rt
[java] ??????????? - ??????????? 7) read by UTF (java getBytes)
[java] K��sel - B�b
[java] �g�l - �lb�rt
[java] ??????????? - ??????????? 8) read by UTF (java getString)
[java] K?sel - B?
[java] ?l - ?b?t
[java] ??????????? - ???????????and here are the results so far
1) it is possible to get every into sync.
JFace, mysql-console, mysqlcc 0.9.4 and java
displayed the same stuff
2) it will only work if i write AND read thru
a UTF-8 enabled connection. which is really no
surprise (not even for me ;-) ).
3) i can get java only than into sync if i read
from a ResultSet via
s = new String(rs.getByte("fieldname"));
i can not use the more natural
s = rs.getString("fieldname");now thing begin to get realy weird if i start to write thru my java-app. - ResultSet.getBytes now returns garbage - ResultSet.getString shows the correct result - JFace shows almost the correct result (a lot of question marks thou) - mysql-console shows only garbage - mysqlcc 0.9.4 shows only garbage
i am really puzzled. why cant i write via java to the db without f***ing up other clients and why cant i read via ResultSet.getString when other clients show the correct results but only thru getBytes?
for any help or hints i'd be incredibly happy.
ciao robertj ps: i hope the utf-8 chars dont get garbled. pps: sorry for the long mail.
smime.p7s
Description: S/MIME Cryptographic Signature
