Mysql: Java Web App and MySql 5.x UTF-8

November 8th, 2008 by jeremychone

To fully support UTF-8 with mysql, make sure of the followings:

  1. Set HttpServletRequest UTF-8 character encoding.
    request.setCharacterEncoding(”UTF-8″);
  2. Set HttpServletResponse UTF-8 character encoding
    response.setContentType(”text/html; charset=UTF-8″);
  3. Create the Column, Table, or DB need to have the UTF8 charset and collation
    CHARACTER SET utf8 COLLATE utf8_general_ci
  4. THE TRICK: Add the character encoding instruction in your JDBC URL
    jdbc:mysql://localhost:3306/DATABASENAME?useUnicode=true&characterEncoding=UTF8

Related links:

Leave a Reply