MySQL database 4.1 is a watershed, and 4.1 directly supports Unicode, which is not supported in the following versions;
MySQL JDBC driver 3.0.16 is also a watershed. Version 3.0.16 will take the database encoding and convert it according to the encoding. This method is the same as that of oracle JDBC driver. For example, if your database is GBK encoded, The JDBC driver will convert the strings in the database to Unicode according to GBK and send them to JVM. Therefore, it is particularly important to correctly set the database encoding.
MySQL JDBC driver3.0.16 or lower version is not, it is not so intelligent according to the database encoding to determine how to convert, it is always the default use of ISO8859-1, therefore, you must use characterencoding = GBK to force it to convert the string obtained from the database to Unicode Based on GBK.
Therefore, what database version is used, whether it is 3.x, 4.0.x or 4.1.x, is not important to us. There are two important aspects:
1) set the correct database encoding, MySQL and earlier versions of the character set is always the default ISO8859-1, mysql4.1 will let you choose when installing. If you are going to use a UTF-8, You need to specify the UTF-8 when creating the database (you can also change it after the creation, 4.1 or a later version can also separately specify the character set of the table)
2) use JDBC driver 3.0.16 or later versions, then you do not need to write what characterencoding = UTF-8
This article from javaeye.com's Robbin in the Forum: http://forum.javaeye.com/viewtopic.php? T = 10317 & START = 45