Modified:
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
branches/branch_5_0/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties
Log:
Driver will now fall back to sane defaults for max_allowed_packet and
net_buffer_length if the server reports them incorrectly (and will log
this situation at WARN level, since it's actually an error condition).
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2007-10-02 19:55:49 UTC (rev 6598)
+++ branches/branch_5_0/connector-j/CHANGES 2007-10-02 22:34:20 UTC (rev 6599)
@@ -69,6 +69,10 @@
- Fixed Bug#27412 - cached metadata with PreparedStatement.execute()
throws NullPointerException.
+
+ - Driver will now fall back to sane defaults for max_allowed_packet and
+ net_buffer_length if the server reports them incorrectly (and will log
+ this situation at WARN level, since it's actually an error condition).
07-19-07 - Version 5.0.7
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java 2007-10-02 19:55:49 UTC (rev 6598)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java 2007-10-02 22:34:20 UTC (rev 6599)
@@ -4075,9 +4075,7 @@
configureTimezone();
if (this.serverVariables.containsKey("max_allowed_packet")) {
- this.maxAllowedPacket = Integer
- .parseInt((String) this.serverVariables
- .get("max_allowed_packet"));
+ this.maxAllowedPacket = getServerVariableAsInt("max_allowed_packet", 1024 * 1024);
int preferredBlobSendChunkSize = getBlobSendChunkSize();
@@ -4090,9 +4088,7 @@
}
if (this.serverVariables.containsKey("net_buffer_length")) {
- this.netBufferLength = Integer
- .parseInt((String) this.serverVariables
- .get("net_buffer_length"));
+ this.netBufferLength = getServerVariableAsInt("net_buffer_length", 16 * 1024);
}
checkTransactionIsolationLevel();
@@ -4224,6 +4220,19 @@
setupServerForTruncationChecks();
}
+ private int getServerVariableAsInt(String variableName, int fallbackValue)
+ throws SQLException {
+ try {
+ return Integer.parseInt((String) this.serverVariables
+ .get(variableName));
+ } catch (NumberFormatException nfe) {
+ getLog().logWarn(Messages.getString("Connection.BadValueInServerVariables", new Object[] {variableName,
+ this.serverVariables.get(variableName), new Integer(fallbackValue)}));
+
+ return fallbackValue;
+ }
+ }
+
/**
* Has the default autocommit value of 0 been changed on the server
* via init_connect?
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties 2007-10-02 19:55:49 UTC (rev 6598)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties 2007-10-02 22:34:20 UTC (rev 6599)
@@ -421,4 +421,4 @@
NotUpdatableReason.7=Result Set not updatable (does not reference all primary keys).
InvalidLoadBalanceStrategy=Invalid load balancing strategy '{0}'.
-
+Connection.Connection.BadValueInServerVariables=Invalid value '{1}' for server variable named '{0}', falling back to sane default of '{3}'.
| Thread |
|---|
| • Connector/J commit: r6599 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc | mmatthews | 3 Oct |