Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Problem with euro symbol with Tomcat and MySql



Good day.

I have a big problem regarding the euro symbol between Tomcat and MySql.
I made a jsp page having a form that contains a textarea.
In it I digit the euro symbol.
The action of a form call a Tomcat's servlet that read a value of the field and write it in a MySql's table via jdbc.
The problem is that in the database the euro symbol is written as ? (question mark).

The environment is a Linux in english with Tomcat 6.0.10 and MySql 5.0.18.
The jdbc driver (5.0.4 but I've tried also the 5.1.18) is setted in a context.xml (Tomcat configuration file) because is in a pool connection and I haven't setted the charset encoding.
The database, the table that I use and any its fields having latin1_swedish_ci as collation.

I have tried to set latin1 as charsetEncoding parameter of the jdbc connection:

I have also setted utf8 as charsetEncoding using as collation of database, table and fields utf8_general_ci
At the end I've tried to set as collation utf8_unicode_ci for database, table and fields with jdbc parameters useUnicode="true" and characterEncoding="UTF-8".

In all these tests the result is allways the same: ? (question mark) write in a table's field.
If I digit it directly in a table via PhpMyAdmin (using all types of collation tested) I haven't problem.

Noted that in the sql query composed in a servlet the euro symbol is correct (I've seen it with System.out.println()).

How can I resolve my problem?

Best regards and good work.

Stefano Errani

Your rating: None