Recently, I surfaced a problem while printing the Japanese / Chinese scripts which I retrieve from the database.
This issue really bugged me for a week. After so much debugging I fixed the issue.
Actual root cause :
The text encoding failed in terms of handling the conversion of Japanese/Chinese script to a string and also the Database collation is set to Latin by default in MySQL when I created my schema, which does not accept such scripts to be entered.
FIX for this issue :
>> Change the default text/character encoding in IDE
Go to the eclipse IDE properties( File->properties or alt+enter ) and change the default text/character encoding as shown below.
This is to ensure that all your text/string conversions are carried out using the specified encoding format
>> Include these parameters in JDBC connection parameters "useUnicode=true&characterEncoding=UTF-8"
EXAMPLE: String databaseUrl = "jdbc:mysql://karthikk.com:1254/testDB?useUnicode=true&characterEncoding=UTF-8"
This is to ensure that the SQL queries which are fired via the code also have the same encoding format.
Note: Use appropriate character Encoding formats as per your requirements
>> Finally change the corresponding column char-set/collation to the same encoding format (as shown below).
Either change the entire table char set/collation to respective formats
OR change the respective column’s char set/collation alone which is used to store such scripts or values