=== modified file 'src/com/mysql/jdbc/CharsetMapping.java' --- src/com/mysql/jdbc/CharsetMapping.java revid:tonci.grgin@oracle.com-20120501202724-k8wpfbrggycn16l8 +++ src/com/mysql/jdbc/CharsetMapping.java 2012-05-14 09:27:07 +0000 @@ -754,6 +754,22 @@ * @throws SQLException if determination of the character encoding fails */ final static String getCharacterEncodingForErrorMessages(ConnectionImpl conn) throws SQLException { + + // As of MySQL 5.5, the server constructs error messages using UTF-8 + // and returns them to clients in the character set specified by the + // character_set_results system variable. + if (conn.versionMeetsMinimum(5, 5, 0)) { + String errorMessageEncodingMysql = conn.getServerVariable("character_set_results"); + if (errorMessageEncodingMysql != null) { + String javaEncoding = conn.getJavaEncodingForMysqlEncoding(errorMessageEncodingMysql); + if (javaEncoding != null) { + return javaEncoding; + } + } + + return "UTF-8"; + } + String errorMessageFile = conn.getServerVariable("language"); if (errorMessageFile == null || errorMessageFile.length() == 0) { === modified file 'src/com/mysql/jdbc/ConnectionImpl.java' --- src/com/mysql/jdbc/ConnectionImpl.java revid:tonci.grgin@oracle.com-20120501202724-k8wpfbrggycn16l8 +++ src/com/mysql/jdbc/ConnectionImpl.java 2012-05-14 09:29:01 +0000 @@ -2028,6 +2028,13 @@ this.serverVariables.put(JDBC_LOCAL_CHARACTER_SET_RESULTS, mysqlEncodingName); } + + // We have to set errorMessageEncoding according to new value + // of charsetResults for server version 5.5 and higher + if (versionMeetsMinimum(5, 5, 0)) { + this.errorMessageEncoding = charsetResults; + } + } else { if (!this.usingCachedConfig) { this.serverVariables.put(JDBC_LOCAL_CHARACTER_SET_RESULTS, onServer);