Java JDBC How to - Store Unicode characters into database


We would like to know how to store Unicode characters into database.


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
//from  w ww .  j ava2s.  co  m
public class Main {

  public static void main(String[] args) throws Exception {
    Connection conn = null;
    conn = DriverManager.getConnection("jdbc:mysql://"
        + "useUnicode=yes&characterEncoding=UTF-8"
        + "&user=root&password=obfuscated");
    String sql = "INSERT INTO `chars` (`value`) VALUES (?)";
    PreparedStatement pst = conn.prepareStatement(sql);
    String var1 = "asdf";
    pst.setString(1, var1);