Reputation: 13
I am working on j2ee project. It is supposed to work width both english and russian language. So I have an EncodingFilter which has mapping ' /* ' and every time do one thing: request.setCharacterEncoding("UTF-8");
I also have MySQL 5.5 installed, the charset of tables and databases is set to utf-8
and collation to utf8_general_ci
.
On my local machine everything works just fine, Russian lang properly stores in db.
Then I tried to test my app on jelastic.com . There I also selected MySQL, imported dump, set charset to utf-8
and collation to utf8_general_ci
. When I am adding russian words to db I only see '?????'. But elder records which came with dump are fine! I have literaly no idea what is wrong.
Upvotes: 1
Views: 231
Reputation: 1108722
You need to tell the MySQL JDBC driver to use UTF-8 as client side encoding instead of the platform default one. If the platform default charset is not UTF-8, then this will result in ?
being stored in the database whenever a character is not covered by the platform default charset which the JDBC driver is using.
You could do that by adding the useUnicode=yes
and characterEncoding=UTF-8
parameters to the JDBC URL. E.g.
jdbc:mysql://localhost:3306/db_name?useUnicode=yes&characterEncoding=UTF-8
That it works on your local Java development environment is likely because you've already configured the platform default charset of your environment to be UTF-8.
Upvotes: 1