skip to Main Content

I am geting data stored as ¥à¤¨à¥ à¤à¤°à¤¨à¥ in mysql . It works fine in localhost but in remote mysql (in plesk) it is not working.
i have used the following:

 request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");

in servlet and

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/projectkkm?useUnicode=yes&characterEncoding=UTF-8","root","");

in database connection

<%@page pageEncoding="UTF-8" %>

in jsp

Now as per my research i found that the problem is in Java.
java for linux do not support hindi text see url: http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html

see this snapshot from oracle

In my localhost (Windows) its work fine but when I deploy it to the centos(linux ) platform its not working.
I think the problem may be in window/linux compatibility.

Can anybody help me to handle this. I am sure problem is not from mysql side.

3

Answers


  1. Chosen as BEST ANSWER
      <Connector URIEncoding="utf-8" connectionTimeout="20000" port="8084" protocol="HTTP/1.1" redirectPort="8443"/>
    

    use above code in your tomcat apache server config file


  2. Seems like your remote db is not configured properly.

    SHOW VARIABLES LIKE 'char%';
    

    should show

    character_set_client      utf8                     
    character_set_connection   utf8               
    character_set_database      utf8                
    character_set_filesystem  binary                    
    character_set_results        utf8                        
    character_set_server         utf8                        
    character_set_system       utf8      
    

    If not you should fix you /etc/mysql/my.cnf

    add the following configs in the [mysqld] section

    character-set-server = utf8
    init-connect='SET NAMES utf8'
    collation-server=utf8_general_ci
    

    put in the [client] and [mysqldump] sections:

    default-character-set=utf8
    

    restart mysql after that

    Login or Signup to reply.
  3. Try adding,

    <filter>
        <filter-name>setCharacterEncodingFilter</filter-name>
        <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>setCharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    

    in web.xml

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search