Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Character encoding problem using java and MySql 5.0

Thread view: 
Dhananjay - 05 May 2006 20:28 GMT
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
Oliver Wong - 05 May 2006 20:35 GMT
> 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
Dhananjay - 06 May 2006 06:17 GMT
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 - 08 May 2006 14:52 GMT
Hi all.

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

Regards
Dhananjay
Oliver Wong - 08 May 2006 15:42 GMT
> 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
Dhananjay - 09 May 2006 07:40 GMT
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
Oliver Wong - 09 May 2006 15:34 GMT
> Hi Oliver,
>
[quoted text clipped - 3 lines]
> 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
Dhananjay - 10 May 2006 07:02 GMT
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 - 10 May 2006 07:03 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.