Character encoding problem using java and MySql 5.0

Discussion in 'Java' started by Dhananjay, May 5, 2006.

  1. Dhananjay

    Dhananjay Guest

    Hi All,

    I am facing a problem for Character encoding that just made me crazy.
    Our user's copies text from different sites and pasting it .

    I m using jboss 3.2.3 and embedded tomcat 4.1.29 and MySql 5.0 as
    backend.

    I have used a filter that set character encoding like this

    request.setCharacterEncoding("Cp1252");

    and our jsp contains the tag :
    <@page pageEncoding="windows-1252">
    <@page contentType="text/html; charset='windows-1252">

    I am using jboss manage connection and mysql-ds.xml setting for mysql
    is as follows:

    jdbcurlformysql?useUnicode=true&amp;characterEncoding=cp1252&amp;charactetrResultSets=cp1252


    If debug the application just before insertion every thing is fine but
    if iretrieve the content its weired and produce ? for some characters
    like

    "left angled double quote", "right angled double quote" etc..

    Thanks in advance..


    Regards
    Dhananjay
    Dhananjay, May 5, 2006
    #1
    1. Advertising

  2. Dhananjay

    Oliver Wong Guest

    "Dhananjay" <> wrote in message
    news:...
    >
    > request.setCharacterEncoding("Cp1252");

    [...]
    > If debug the application just before insertion every thing is fine but
    > if iretrieve the content its weired and produce ? for some characters
    > like
    >
    > "left angled double quote", "right angled double quote" etc..


    Here's a list of all the characters supported by Cp1252:
    http://www.microsoft.com/typography/unicode/1252.htm

    If the character you're trying to represent doesn't exist, then the
    encoder will save it as a question mark as you've seen. The solution is to
    use a different encoding (e.g. UTF-8).

    - Oliver
    Oliver Wong, May 5, 2006
    #2
    1. Advertising

  3. Dhananjay

    Dhananjay Guest

    Hi Oliver,

    Thanks for your positive response.

    The characters those are creating problem are available in Cp1252. Some
    are:
    82 201A SINGLE LOW-9 QUOTATION MARK
    84 201E DOUBLE LOW-9 QUOTATION MARK
    91 2018 LEFT SINGLE QUOTATION MARK

    etc.

    Recently the same application was running on Oracle 9i and the same
    problem were there.

    But we solved the problem using following approach:

    1. Apply a filter that do like this:
    request.setCharacterEncoding("Cp1252");

    2. The encoding parameter for for Oracle was
    NLS_CHARACTERSET : WE8MSWIN1252

    3. Jsp settings were as follows;
    <%@ page contentType="text/html; charset=windows-1252"
    language="java"%>
    <%@ page pageEncoding="windows-1252"%>

    And all are running fine.

    But i don't know why this doesn't wiork in MySQl.

    Regards
    Dhananjay
    Dhananjay, May 6, 2006
    #3
  4. Dhananjay

    Dhananjay Guest

    Hi all.

    I still couldn't solve the problem.
    Please help me out.

    Regards
    Dhananjay
    Dhananjay, May 8, 2006
    #4
  5. Dhananjay

    Oliver Wong Guest

    "Dhananjay" <> wrote in message
    news:...
    > Hi all.
    >
    > I still couldn't solve the problem.
    > Please help me out.


    In a previous message, you wrote that you had solved the problem. Should
    we disregard that message and try to help you with the original problem, or
    are you experiencing some new problem with different symptoms now?

    - Oliver
    Oliver Wong, May 8, 2006
    #5
  6. Dhananjay

    Dhananjay Guest

    Hi Oliver,

    I've tried to write that , "I was facing same problem on Oracle but
    this was solved"

    But on mysql same problem is comming up.
    The approach worked on Oracle is not working on mysql.

    Your help is appreciable.

    Regards
    Dhananjay
    Dhananjay, May 9, 2006
    #6
  7. Dhananjay

    Oliver Wong Guest

    "Dhananjay" <> wrote in message
    news:...
    > Hi Oliver,
    >
    > I've tried to write that , "I was facing same problem on Oracle but
    > this was solved"
    >
    > But on mysql same problem is comming up.
    > The approach worked on Oracle is not working on mysql.
    >


    Can you use a seperate tool (e.g. mysqladmin) to check whether the data
    is correctly stored in the table? That is, is the data getting corrupted
    when you store it, or when you retrieve it? Have you set the encoding on the
    tables?

    - Oliver
    Oliver Wong, May 9, 2006
    #7
  8. Dhananjay

    Dhananjay Guest

    Hi oliver,

    Thanks for ur kind help .
    Now I solved the problem by following approach:

    I have used a filter that set character encoding like this

    request.setCharacterEncoding("Cp1252");

    and our jsp contains the tag :
    <@page pageEncoding="windows-1252">
    <@page contentType="text/html; charset='windows-1252">

    I am using jboss manage connection and mysql-ds.xml setting for mysql
    is as follows:

    jdbcurlformysql?useUnicode=true&amp;characterEncoding=utf8&amp;charactetrResultSets=utf8


    Regards,
    Dhananjay
    Dhananjay, May 10, 2006
    #8
  9. Dhananjay

    Dhananjay Guest

    Hi oliver,

    Thanks for ur kind help .
    Now I solved the problem by following approach:

    I have used a filter that set character encoding like this

    request.setCharacterEncoding("Cp1252");

    and our jsp contains the tag :
    <@page pageEncoding="windows-1252">
    <@page contentType="text/html; charset='windows-1252">

    I am using jboss manage connection and mysql-ds.xml setting for mysql
    is as follows:

    jdbcurlformysql?useUnicode=true&amp;characterEncoding=utf8&amp;charactetrResultSets=utf8


    One more thing:

    My database level encoding is utf8 as well as table level encoding.

    Regards,
    Dhananjay
    Dhananjay, May 10, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raavi
    Replies:
    2
    Views:
    909
    raavi
    Mar 2, 2006
  2. Roedy Green
    Replies:
    0
    Views:
    1,471
    Roedy Green
    Jul 23, 2009
  3. Mario Ruiz
    Replies:
    3
    Views:
    187
    Mario Ruiz
    Oct 26, 2010
  4. peter
    Replies:
    0
    Views:
    128
    peter
    Dec 7, 2012
  5. Chris Angelico
    Replies:
    0
    Views:
    162
    Chris Angelico
    Dec 7, 2012
Loading...

Share This Page