Fixes bugs found since release 5.1.13.
Functionality added or changed:
Connector/J's load-balancing functionality only allowed the following events to trigger failover:
Transaction commit/rollback
CommunicationExceptions
Matches to user-defined Exceptions using the loadBalanceSQLStateFailover, loadBalanceSQLExceptionSubclassFailover or loadBalanceExceptionChecker property.
This meant that connections where auto-commit was enabled were not balanced, except for Exceptions, and this was problematic in the case of distribution of read-only work across slaves in a replication deployment.
The ability to load-balance while auto-commit is enabled has now been added to Connector/J. This introduces two new properties:
loadBalanceAutoCommitStatementThreshold - defines the number of matching statements which will trigger the driver to (potentially) swap physical server connections. The default value (0) retains the previously-established behavior that connections with auto-commit enabled are never balanced.
loadBalanceAutoCommitStatementRegex - the regular expression against which statements must match. The default value (blank) matches all statements.
Load-balancing will be done after the statement is executed, before control is returned to the application. If rebalancing fails, the driver will silently swallow the resulting Exception (as the statement itself completed successfully). (Bug#55723)
Bugs fixed:
Connector/J mapped both 3-byte and 4-byte UTF8 encodings to the same Java UTF8 encoding.
To use 3-byte UTF8 with Connector/J set
characterEncoding=utf8
and setuseUnicode=true
in the connection string.To use 4-byte UTF8 with Connector/J configure the MySQL server with
character_set_server=utf8mb4
. Connector/J will then use that setting as long ascharacterEncoding
has not been set in the connection string. This is equivalent to autodetection of the character set. (Bug#58232)The
CallableStatementRegression
test suite failed with a Null Pointer Exception because theOUT
parameter in theI__S.PARAMETERS
table had no name, that isCOLUMN_NAME
had the valueNULL
. (Bug#58232)DatabaseMetaData.supportsMultipleResultSets()
was hard-coded to returnfalse
, even though Connector/J supports multiple result sets. (Bug#57380)Using the
useOldUTF8Behavior
parameter failed to set the connection character set tolatin1
as required.In versions prior to 5.1.3, the handshake was done using
latin1
, and while there was logic in place to explicitly set the character set after the handshake was complete, this was bypassed whenuseOldUTF8Behavior
was true. This was not a problem until 5.1.3, when the handshake was modified to useutf8
, but the logic continued to allow the character set configured during that handshake process to be retained for later use. As a result,useOldUTF8Behavior
effectively failed. (Bug#57262)Invoking a stored procedure containing output parameters by its full name, where the procedure was located in another database, generated the following exception:
Parameter index of 1 is out of range (1, 0)
When a JDBC client disconnected from a remote server using
Connection.close()
, the TCP connection remained in theTIME_WAIT
state on the server side, rather than on the client side. (Bug#56979)Leaving Trust/ClientCertStoreType properties unset caused an exception to be thrown when connecting with
useSSL=true
, as no default was used. (Bug#56955)When load-balanced connections swap servers, certain session state was copied from the previously active connection to the newly-selected connection. State synchronized included:
Auto-commit state
Transaction isolation state
Current schema/catalog
However, the read-only state was not synchronized, which caused problems if a write was attempted on a read-only connection. (Bug#56706)
When using Connector/J configured for failover (jdbc:mysql://host1,host2,... URLs), the non-primary servers re-balanced when the transactions on the master were committed or rolled-back. (Bug#56429)
An unhandled Null Pointer Exception (NPE) was generated in
DatabaseMetaData.java
when calling an incorrectly cased function name where no permission to accessmysql.proc
was available.In addition to catching potential NPEs, a guard against calling JDBC functions with
db_name.proc_name
notation was also added. (Bug#56305)Attempting to use JDBC4 functions on
Connection
objects resulted in errors being generated:Exception in thread "main" java.lang.AbstractMethodError: com.mysql.jdbc.LoadBalancedMySQLConnection.createBlob()Ljava/sql/Blob; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.mysql.jdbc.LoadBalancingConnectionProxy.invoke(LoadBalancingConnectionProxy.java:476) at $Proxy0.createBlob(Unknown Source)