Well, I have a problem with reading from MySql database (db). I use MySQL version: 5.5.20, mysql-connector-java-5.1.14-bin.jar and jre6. I start MySql server with: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci (utf-8 representation in MySql).
Eveything, I write from Java application into MySql database works O.K. I can see our special national characters in database excatly as I wrote (or as I would write) them directly in the phpmyadmin (databse editor written in php).
The only problem is that I can't read special national characters from database. I see some graphical symbols instead of my desired national characters. Java uses UTF-16 character representation, but MySql in my case uses utf-8. So, I can belive, that "mysql-connector-java-5.1.14-bin.jar" correctly converts from utf-16 to utf-8 automaticly (so here I talk about writing to database). I DON'T KNOW, WHY THIS CONVERSION (utf-8 in MySql -> utf-16 in java) DOESN'T WORK IN THE OPPOSITE DIRECTION (JAVA READING FROM DATABASE)? Well, reading from Java it doesn't work also when I write my special national characters directly in databse (so I can see my national characters in datbase correctly) through MySql database editor phpmyadmin.
[Edit: removed excessive use of bold and uppercase]
How do you display the data after reading them from the database? There certainly is a possibility they are correctly read, but your font cannot properly display them. Also Windows consoles are notoriously known to be unable to display various encoding correctly.
I'd suggest to write the data obtained from the database into a file (making sure the encoding of the output file is properly set) and inspecting the contents of the file, to verify that the data are actually being read wrongly from the database.
Joined: Feb 21, 2009
Hello Mr. Martin
After reading from database I display message as follows:
I will try with file as you've suggested.
Thank you for reply,
Joined: Feb 21, 2009
I've tried your idea about writing to file. It works O.K.