In recent days I had a problem in printing the Japanese / Chinese scripts which are entered by the end user in my application. 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 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).

Alter table

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

Add comment
  • No comments found