2

I am trying to insert some data into mysql DB via Java JDBC that contains some International characters.

INSERT INTO my_table (`name`, `lat`, `long`, `label`) VALUES('Ädelfors folkhögskola', '57.43611145019531', '15.19722175598145', 'Ädelfors folkhögskola')

This query works perfectly fine if i use it directly from mysqlworkbench, phpmyadmin, etc but when i try with java JDBC the international characters are completely garbled

Ädelfors folkhögskola =>  ?��delfors folkh??gskola

the solutions i have tried till now include

jdbc:mysql://server/database?characterEncoding=UTF-8

Setting - Dfile.encoding=UTF-8
Both my database and table are encoded as utf8 - default collation

this is the dump of "show variables like '%char%'"

character_set_client - utf8

character_set_connection - utf8

character_set_database - utf8

character_set_filesystem - binary

character_set_results - utf8

character_set_server - latin1

character_set_system - utf8

character_sets_dir - /usr/share/mysql/charsets/

I have tried using both preparesStatements as well as normal Statement

I know there are many similar questions and i have referred most of them but could find a solution.

Some info about environment... OS - Mac osx 10.6.8 IDE - netbeans

mysql 5.5.23 running on ubuntu

Pragati Sureka
  • 1,412
  • 12
  • 18
  • check the following post and see the accepted answer. I belive you need to set the connection to use unicode. http://stackoverflow.com/questions/8433293/how-can-i-insert-arabic-word-to-mysql-database-using-java –  Jul 25 '12 at 14:55
  • I have already tried that, i forgot to mention jdbc:mysql://server/database?useUnicode=yes&characterEncoding=UTF-8 – Pragati Sureka Jul 25 '12 at 16:12
  • @PragatiSureka: How do you getting data ? and if using JSP then what is the encoding – Hardik Mishra Jul 26 '12 at 05:08
  • Please, post the `show create table my_table` result. – nashuald Nov 21 '12 at 16:11

1 Answers1

0

If you typed your query in a java source or property file you have use an utf-8 editor.
If you are using eclipse (Preferences>General>Workspaces and set text encoding)