MySQL Connector/J 5.1 Release Notes

2.27 Changes in MySQL Connector/J 5.1.23 (2013-02-05)

Fixes bugs found since release 5.1.22. Also adds support and test cases for several new features from MySQL Server 5.6.

Functionality Added or Changed

  • New test cases cover new features from MySQL Server 5.6:

    • Explicit partition selection syntax.

    • EXCHANGE PARTITION syntax.

    • Transportable tablespaces syntax: LOCK TABLES ... FOR EXPORT.

    • CREATE TABLE ... DATA DIRECTORY = '/absolute/path/to/directory/' syntax for InnoDB tables.

    • New ALTER TABLE syntax: ALGORITHM and LOCK keywords.

  • Added support of password expiration protocol. This introduces a new Boolean connection property disconnectOnExpiredPasswords:

    • If disconnectOnExpiredPasswords=true and the password has expired, the connection will be rejected by server with ErrorCode == 1820 (ER_MUST_CHANGE_PASSWORD).

    • If disconnectOnExpiredPasswords=false, the connection enters sandbox mode, where all commands except SET PASSWORD = ... and SET PASSWORD FOR CURRENT_USER() = ... cause an error to be thrown. The user needs to reconnect though, after setting the password, because Connector/J requires additional information from the server that is not available in the sandbox mode.

  • Static charset/collation maps were updated, particularly for the ucs2_unicode_ci and utf8_unicode_ci collations.

  • Connection.setReadOnly() will take advantage of server-side support for read-only transactions present in MySQL 5.6 and newer. Calling .isReadOnly() will incur a round-trip if useLocalSessionState is not enabled.

  • The driver now allows the mechanism for caching MySQL server configuration values replaceable at runtime, via the serverConfigCacheFactory property. The default is an implementation that is a per-VM concurrent map, keyed by URL. The driver will invalidate cache entries when SQLException exceptions that indicate communications errors are thrown (on the assumption that the server has been or is restarting). The driver also invalidates cache entries if the server version that is being connected to differs from the one that was present when the cached values were populated.

    To replace the default implementation, implement CacheAdapterFactory<String, Map<String, String>>, and specify the fully-qualified class name of this implementation for the serverConfigCacheFactory connection option.

Bugs Fixed

  • Stack trace used for point-of-origin in log and exception messages caused a Permgen leak when an application was redeployed, because the WebappClassloader could not be garbage collected. We no longer store the entire stack trace, only the calling class and method, and only when using the usage advisor or when profiling. (Bug #16097851, Bug #67954)

  • With the connection setting useCompression=true, the SQL statement LOAD DATA LOCAL could cause a java.net.SocketException error due to a broken pipe. (Bug #15895369, Bug #11237)

  • The nativeSQL() method would always truncate fractional seconds rather than preserving the fractional part in the output string. Now Connector/J checks the server version: it preserves the fractional part for MySQL 5.6.4 and greater, and truncates the fractional part for older versions. (Bug #14748459, Bug #60598)

  • With the new MySQL server password hashing feature enabled, different results could be returned from ResultSet and CachedRowSet. The test suite was modified to not perform comparison of PASSWORD() results when the setting old_passwords=2, because with SHA-256 password hashing enabled, the function return results are nondeterministic. (Bug #14665141)

  • The cleanup thread for abandoned connections in the NonRegisteringDriver class was refactored to have a static shutdown method. Memory was allocated but never released. If you encountered this leak problem, implement the context listener in your application with the AbandonedConnectionCleanupThread.shutdown() call in the contextDestroyed method. This issue was found in applications running under the Tomcat application server, but it might have also applied to other application servers.

    For example:

    @WebListener
    public class YourThreadsListener implements ServletContextListener {
       public void contextDestroyed(ServletContextEvent arg0) {
          try {
              AbandonedConnectionCleanupThread.shutdown();
          } catch (InterruptedException e) {
          }
       }
       ...
    }
    

    Note that if container does not support annotations, you add the description to web.xml:

    <listener>
       <listener-class>user.package.YourThreadsListener</listener-class>
    </listener>
    
    

    (Bug #14570236, Bug #65909)

  • With the connection parameter rewriteBatchedStatements=true, ResultSetRow.getTimeFast could give an incorrect value for TIME columns containing a fractional part. (Bug #14260352)

  • If a timestamp value was passed through prepared statement parameters, fractional-second precision was stripped off, even if the underlying field (such as VARCHAR(255)) could store the full value. A workaround was to convert the timestamp value to a string when specifying the prepared statement argument, for example prepped_stmt.setString(1,time_stamp.toString(). This was partly fixed in 5.1.19, but that fix did not cover the case with the setting useLegacyDatetimeCode=true. (Bug #11750017, Bug #40279, Bug #60584)

  • executeQuery() in Statement.java let TRUNCATE TABLE queries be executed, although that method is supposed to block any request that modifies the database. TRUNCATE TABLE and RENAME TABLE are now filtered for executeQuery(). (Bug #11748257, Bug #35653)

  • Compiling Connector/J from source failed when using a non-Sun/Oracle JDK, because the Ant target compile-testsuite contained a AppletRegressionTest that used a Sun-specific class (sun.applet.AppletSecurity). This fix removes the AppletRegressionTest and thus the dependence on the Sun class from the build process. (Bug #11745319, Bug #13509)