0

I am getting this string which contains this substring gratuit.AFLĂ MAI MULTEDe from webservice. when i save this in data base in my local(windows) works fine but when i try to save on server when it is deployed on linux i get following error:

Incorrect string value: '\xC4\x82 MAI...' for column 'description' at row 1

I am using hibernate 3.3 with mysql 5.5 (both windows and linux) and database usage default encoding (latin1).

I have tried setting -Dfile.encoding=UTF8 in JAVA_OPT but not worked, i think its this is os related problem.

Any suggestion?

Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46

1 Answers1

0

(In general nowadays I would do all in UTF-8.) There is a long pipeline of points where encoding can be set. From the web service you get probably XML in UTF-8. That is automatically read correctly, as XML handles the encoding strict.

On database level there is the database and table and field with a default and explicit encoding. Furthermore the connection url should be parametrised to the correct encoding.

The error message shows the UTF-8 bytes for that accented A and I guess it is not available in Latin1. For MySQL the connection string could look like:

jdbc:mysql://localhost/MYDB?useUnicode=true&characterEncoding=UTF-8
Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • You have to use an utf8 collation for your database. Then, specifying the encoding in the connection string as advised by the answer. – dodecaplex Jul 18 '12 at 13:30