Bug #3514 useUnicode=false has no effect
Submitted: 20 Apr 2004 5:59 Modified: 21 Apr 2004 6:39
Reporter: Christian Gruber Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.0.11 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[20 Apr 2004 5:59] Christian Gruber
Description:
Hello!

Switching off unicode support does not work. In case of databases that are known not to contain any non-ascii encodings, the unicode en/decoding procedures can be time (and especially memory) consuming, especially when handling LONGTEXT columns. I tried to switch unicode awareness off, in the hope that the special character de/encodings do not take place. I used the parameter "useUnicode=false" in the connection string, but connection.useUnicode() still returns "true"...

How to repeat:
import java.sql.*;

public class MySQLUnicode {

    public static void main (String[] argv)
    {
        try {
            String url = "jdbc:mysql://host:port/db?user=x&password=y&useUnicode=false";

            Class.forName("com.mysql.jdbc.Driver").newInstance();
            
            Connection conn =
                DriverManager.getConnection (url);

            System.out.println("Connection URL: " + url);
            System.out.println(conn.getMetaData().getDatabaseProductName() +
                               " " +
                               conn.getMetaData().getDatabaseProductVersion());
            System.out.println(conn.getMetaData().getDriverName() + " " +
                               conn.getMetaData().getDriverVersion());

            System.out.println("Unicode: " +
                               ((com.mysql.jdbc.Connection)conn).useUnicode());

            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

Output:

Connection URL: jdbc:mysql://host:port/db?user=x&password=y&useUnicode=false
MySQL 4.0.18-standard-log
MySQL-AB JDBC Driver mysql-connector-java-3.0.11-stable ( $Date: 2004/02/04 02:47:36 $, $Revision: 1.27.2.34 $ )
Unicode: true

Suggested fix:
?
[21 Apr 2004 6:23] Mark Matthews
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php
[21 Apr 2004 6:39] Mark Matthews
If you're using a single-byte character set, the same code will be used whether or not you specify useUnicode in your JDBC URL.

The driver does not use the Sun classes for character conversion for single-byte character sets.