Saving serbian latin characters in database
I have problem with saving ser开发者_如何学运维bian latin characters in database, but only when I save it from my jsf application. When I inserting some rows in database directly using SQLyog, everything is fine. When I try insert something from application instead of characters: č
, ć
and đ
in database are inserted question marks.
On the other hand, when I read that row from database everything is shown correctly, without question marks.
When I try insert something from application instead of characters: č, ć and đ in database are inserted question marks.
In other words, the MySQL JDBC driver doesn't support the character encoding in which the characters are originally been submitted with. The MySQL JDBC driver defaults to the platform default encoding when sending character data to the DB, which may be for example ISO 8859-1. You need to tell it not to do that by specifying the useUnicode
and characterEncoding
parameters in the JDBC URL.
jdbc:mysql://localhost:3306/db_name?useUnicode=yes&characterEncoding=UTF-8
When you're using Facelets as view technology, JSF defaults by itself already to UTF-8 when it comes to rendering HTML content and processing submitted parameter values. So the problem is at least not in there.
See also:
- Unicode - How to get the characters right? - Databases
- MySQL Connector/J Manual - 19.3.4.4. Using Character Sets and Unicode
精彩评论