How to insert non-English languages to Mysql database using Hibernate ?

Fellas,

Here i’m going to tell you some information from my own experience. The question simply is how to insert non-English languages to mysql database using hibernate. By going through the following 3-4 steps, you can also solve your problem (only if you are facing it !), So let me start..

Step 1 : Set the default character set and collate of your database to utf8 and utf8_general_ci consecutively; by default it will be ‘latin1’. The alter query for the above purpose is..
ALTER DATABASE `dbname` CHARACTER SET utf8 COLLATE utf8_general_ci;

Step 2 : Set the default character set of your table to ‘UTF8’ as well. The query looks like this..
ALTER TABLE `tblname` CHARACTER SET utf8;

Step 3 : Change the character set of your table column to utf8.
ALTER TABLE `tblname` MODIFY `columnname` `datatype` CHARACTER SET utf8;

Step4 : Make sure that the encoding type of your JSP page is UTF-8. For that, just include this line above all of your JSP pages.

<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

Step5 : The final step.. Add these two properties to your hibernate configuration file.

Now clean and build your project, just enter a non-English language(Eg: Arabic) in the text box of your jsp page, then save it. Now you can see how it works..

Thank you..