Home » Uncategorized » Unicode UTF-8 Java & Mysql di MS.Windows

Unicode UTF-8 Java & Mysql di MS.Windows

Start here

win1

default Ms.Windows encoding use  “CP-1252” or latin1 notUTF-8“, it turns out that cause of my applications (forked and add some modification from -> https://github.com/virkt/Who_Wants_To_Be_A_Millionaire) that run well on Ubuntu but not in Ms.Windows, the same problem for web designers when dealing with “ie” 😉

on Ubuntu oke2 aja:

linux

go to Win7…. chaos :

windows

some notes:

1. ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;

2. ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;

3. add after jdbc connection url
  url+?useUnicode=yes&characterEncoding=UTF-8
if use mybatis add on DataSourceFactory ->
on xml config :
   <property name=”driver.encoding” value=”UTF-8″></property>
or if not use  xml config:
Properties prop2 = new Properties();
prop2.setProperty(“driver.encoding”, “utf-8”);  
PooledDataSource dataSource = new PooledDataSource(driver, url,prop2);

4. if necessary, can also create a new string

   new String(soal.getPertanyaan().getBytes(),”UTF-8″)

5. and last try to add to the  jvm property

   java -Dfile.encoding=UTF8

and finally itextpdf also was going well.

 score


Leave a comment