views:

292

answers:

2

I have a project where I scrape some data from a HTML file, put it into a MySQL database and then read it out again and display it to the user. Whenever the servlet is inserting something into the DB the "£" sign is being inserted as a � and when read out again presented as that.

The application is written in Java (with Spring) and JPA with EclipseLink as the JPA implementation.

I have narrowed down the problem to the insertion into MySQL since when I view the table in the console the question mark appears.

I have configured MySQL to use UTF-8 as the standard encoding in my.cnf

[mysqld]
default-character-set=utf8

If I run

SHOW TABLE STATUS;

I can see that the collation on the tables is

utf8_general_ci

which suggests that the char set is also UTF-8.

Also there is this: mysql> SHOW CREATE DATABASE gate;

+----------+---------------------------------------------------------------+
| Database | Create Database                                               |
+----------+---------------------------------------------------------------+
| gate     | CREATE DATABASE `gate` /*!40100 DEFAULT CHARACTER SET utf8 */ | 
+----------+---------------------------------------------------------------+
1 row in set (0.00 sec)

So, with Java being fully unicode(?) and my DB being set to UTF-8 where could I look for misconfigurations/errors?

A: 

Do you have:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

in your HTML page?

dutch
A: 

What is your connection character set? Take a look at Connect/J configuration properties as well as a section on dealing with charsets

ChssPly76