Character encoding problem using java and MySql 5.0

D

Dhananjay

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
 
O

Oliver Wong

Dhananjay said:
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
 
D

Dhananjay

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
 
D

Dhananjay

Hi all.

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

Regards
Dhananjay
 
O

Oliver Wong

Dhananjay said:
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
 
D

Dhananjay

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
 
O

Oliver Wong

Dhananjay said:
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
 
D

Dhananjay

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
 
D

Dhananjay

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top