I have a stand alone java program that opens a text file in UTF-8 mode and read each line in the file containing Swedish characters like å, ä, ö. The text file has been saved in utf-8 mode. The java program prints what it reads from the file into standard output and I have verified that the program can read and print these special characters properly. The program then saves this data it read from the file into a Mysql 5.5 database with default utf-8 collation by using a JDBC connection.
Nevertheless, when the program inserts these textual data with the Swedish characters into the mysql database, the special characters are replaced with weird black characters that are not readable. If I change the database collation to latin1 instead, then all these special characters are removed by the MySQL server. I have googled the issue and found suggestions involving the use variations of utf-8 and latin1 as the default database collation but non of them seems to have helped me so far.
I wonder if there is anyone facing a similar issue on placing Swedish characters in a mysql database? If so, could you tell me what is the collation type and charset I should be using to have swedish charecters correctly in the database. Do I have to make a specific setting in JDBC database connection for these letters to be saved correctly? Perhaps the issue is more java related but I verified visually that my java program can read/print these characters properly. Thanks.