Modified:
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java
branches/branch_5_1/connector-j/CHANGES
branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionProperties.java
Log:
Fixed BUG#19169 - ConnectionProperties (and thus some subclasses) are not serializable, even though some J2EE containers
expect them to be.
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2006-06-16 17:38:04 UTC (rev 5398)
+++ branches/branch_5_0/connector-j/CHANGES 2006-06-16 17:55:13 UTC (rev 5399)
@@ -14,6 +14,10 @@
of the "language" server variable to the character set that
is used for error messages.
+ - Fixed BUG#19169 - ConnectionProperties (and thus some
+ subclasses) are not serializable, even though some J2EE containers
+ expect them to be.
+
12-23-05 - Version 5.0.0-beta
- XADataSource implemented (ported from 3.2 branch which won't be
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-06-16 17:38:04 UTC (rev 5398)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-06-16 17:55:13 UTC (rev 5399)
@@ -28,6 +28,7 @@
import com.mysql.jdbc.log.Log;
import com.mysql.jdbc.log.StandardLogger;
+import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.sql.DriverPropertyInfo;
@@ -52,8 +53,14 @@
* @version $Id: ConnectionProperties.java,v 1.1.2.2 2005/05/17 14:58:56
* mmatthews Exp $
*/
-public class ConnectionProperties {
- class BooleanConnectionProperty extends ConnectionProperty {
+public class ConnectionProperties implements Serializable {
+
+ private static final long serialVersionUID = 4257801713007640580L;
+
+ class BooleanConnectionProperty extends ConnectionProperty implements Serializable {
+
+ private static final long serialVersionUID = 2540132501709159404L;
+
/**
* DOCUMENT ME!
*
@@ -117,7 +124,7 @@
}
}
- abstract class ConnectionProperty extends DriverPropertyInfo {
+ abstract class ConnectionProperty implements Serializable {
String[] allowableValues;
String categoryName;
@@ -136,12 +143,17 @@
Object valueAsObject;
+ boolean required;
+
+ String description;
+
+ public ConnectionProperty() {}
+
ConnectionProperty(String propertyNameToSet, Object defaultValueToSet,
String[] allowableValuesToSet, int lowerBoundToSet,
int upperBoundToSet, String descriptionToSet,
String sinceVersionToSet, String category, int orderInCategory) {
- super(propertyNameToSet, null);
-
+
this.description = descriptionToSet;
this.propertyName = propertyNameToSet;
this.defaultValue = defaultValueToSet;
@@ -242,15 +254,16 @@
}
}
- /**
- * Synchronizes the state of a ConnectionProperty so that it can be
- * exposed as a DriverPropertyInfo instance.
- */
- void syncDriverPropertyInfo() {
- this.choices = getAllowableValues();
- this.value = (this.valueAsObject != null) ? this.valueAsObject
- .toString() : null;
+ DriverPropertyInfo getAsDriverPropertyInfo() {
+ DriverPropertyInfo dpi = new DriverPropertyInfo(this.propertyName, null);
+ dpi.choices = getAllowableValues();
+ dpi.value = (this.valueAsObject != null) ? this.valueAsObject.toString() : null;
+ dpi.required = this.required;
+ dpi.description = this.description;
+
+ return dpi;
}
+
void validateStringValues(String valueToValidate) throws SQLException {
String[] validateAgainst = getAllowableValues();
@@ -303,7 +316,10 @@
}
}
- class IntegerConnectionProperty extends ConnectionProperty {
+ class IntegerConnectionProperty extends ConnectionProperty implements Serializable {
+
+ private static final long serialVersionUID = -8147538210820248187L;
+
int multiplier = 1;
IntegerConnectionProperty(String propertyNameToSet,
@@ -408,8 +424,10 @@
}
}
- class MemorySizeConnectionProperty extends IntegerConnectionProperty {
+ class MemorySizeConnectionProperty extends IntegerConnectionProperty implements Serializable {
+ private static final long serialVersionUID = 7351065128998572656L;
+
MemorySizeConnectionProperty(String propertyNameToSet,
int defaultValueToSet, int lowerBoundToSet,
int upperBoundToSet, String descriptionToSet,
@@ -461,7 +479,10 @@
}
}
- class StringConnectionProperty extends ConnectionProperty {
+ class StringConnectionProperty extends ConnectionProperty implements Serializable {
+
+ private static final long serialVersionUID = 5432127962785948272L;
+
StringConnectionProperty(String propertyNameToSet,
String defaultValueToSet, String descriptionToSet,
String sinceVersionToSet, String category, int orderInCategory) {
@@ -1402,8 +1423,8 @@
propToExpose.initializeFrom(info);
}
- propToExpose.syncDriverPropertyInfo();
- driverProperties[i] = propToExpose;
+
+ driverProperties[i] = propToExpose.getAsDriverPropertyInfo();
} catch (IllegalAccessException iae) {
throw SQLError.createSQLException("Internal properties failure",
SQLError.SQL_STATE_GENERAL_ERROR);
@@ -1517,8 +1538,7 @@
while (orderedIter.hasNext()) {
ConnectionProperty propToGet = (ConnectionProperty) orderedIter
.next();
- propToGet.syncDriverPropertyInfo();
-
+
xmlBuf.append("\n <Property name=\"");
xmlBuf.append(propToGet.getPropertyName());
xmlBuf.append("\" required=\"");
@@ -1543,8 +1563,7 @@
while (alphaIter.hasNext()) {
ConnectionProperty propToGet = (ConnectionProperty) alphaIter
.next();
- propToGet.syncDriverPropertyInfo();
-
+
xmlBuf.append("\n <Property name=\"");
xmlBuf.append(propToGet.getPropertyName());
xmlBuf.append("\" required=\"");
Modified: branches/branch_5_1/connector-j/CHANGES
===================================================================
--- branches/branch_5_1/connector-j/CHANGES 2006-06-16 17:38:04 UTC (rev 5398)
+++ branches/branch_5_1/connector-j/CHANGES 2006-06-16 17:55:13 UTC (rev 5399)
@@ -16,6 +16,10 @@
of the "language" server variable to the character set that
is used for error messages.
+ - Fixed BUG#19169 - ConnectionProperties (and thus some
+ subclasses) are not serializable, even though some J2EE containers
+ expect them to be.
+
12-23-05 - Version 5.0.0-beta
- XADataSource implemented (ported from 3.2 branch which won't be
Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionProperties.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-06-16 17:38:04 UTC (rev 5398)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-06-16 17:55:13 UTC (rev 5399)
@@ -28,6 +28,7 @@
import com.mysql.jdbc.log.Log;
import com.mysql.jdbc.log.StandardLogger;
+import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.sql.DriverPropertyInfo;
@@ -52,8 +53,14 @@
* @version $Id: ConnectionProperties.java,v 1.1.2.2 2005/05/17 14:58:56
* mmatthews Exp $
*/
-public class ConnectionProperties {
- class BooleanConnectionProperty extends ConnectionProperty {
+public class ConnectionProperties implements Serializable {
+
+ private static final long serialVersionUID = 4257801713007640580L;
+
+ class BooleanConnectionProperty extends ConnectionProperty implements Serializable {
+
+ private static final long serialVersionUID = 2540132501709159404L;
+
/**
* DOCUMENT ME!
*
@@ -117,7 +124,7 @@
}
}
- abstract class ConnectionProperty extends DriverPropertyInfo {
+ abstract class ConnectionProperty implements Serializable {
String[] allowableValues;
String categoryName;
@@ -136,11 +143,16 @@
Object valueAsObject;
+ boolean required;
+
+ String description;
+
+ public ConnectionProperty() {}
+
ConnectionProperty(String propertyNameToSet, Object defaultValueToSet,
String[] allowableValuesToSet, int lowerBoundToSet,
int upperBoundToSet, String descriptionToSet,
String sinceVersionToSet, String category, int orderInCategory) {
- super(propertyNameToSet, null);
this.description = descriptionToSet;
this.propertyName = propertyNameToSet;
@@ -242,14 +254,14 @@
}
}
- /**
- * Synchronizes the state of a ConnectionProperty so that it can be
- * exposed as a DriverPropertyInfo instance.
- */
- void syncDriverPropertyInfo() {
- this.choices = getAllowableValues();
- this.value = (this.valueAsObject != null) ? this.valueAsObject
- .toString() : null;
+ DriverPropertyInfo getAsDriverPropertyInfo() {
+ DriverPropertyInfo dpi = new DriverPropertyInfo(this.propertyName, null);
+ dpi.choices = getAllowableValues();
+ dpi.value = (this.valueAsObject != null) ? this.valueAsObject.toString() : null;
+ dpi.required = this.required;
+ dpi.description = this.description;
+
+ return dpi;
}
void validateStringValues(String valueToValidate) throws SQLException {
@@ -303,7 +315,10 @@
}
}
- class IntegerConnectionProperty extends ConnectionProperty {
+ class IntegerConnectionProperty extends ConnectionProperty implements Serializable {
+
+ private static final long serialVersionUID = -8147538210820248187L;
+
int multiplier = 1;
IntegerConnectionProperty(String propertyNameToSet,
@@ -408,8 +423,10 @@
}
}
- class MemorySizeConnectionProperty extends IntegerConnectionProperty {
+ class MemorySizeConnectionProperty extends IntegerConnectionProperty implements Serializable {
+ private static final long serialVersionUID = 7351065128998572656L;
+
MemorySizeConnectionProperty(String propertyNameToSet,
int defaultValueToSet, int lowerBoundToSet,
int upperBoundToSet, String descriptionToSet,
@@ -461,7 +478,10 @@
}
}
- class StringConnectionProperty extends ConnectionProperty {
+ class StringConnectionProperty extends ConnectionProperty implements Serializable {
+
+ private static final long serialVersionUID = 5432127962785948272L;
+
StringConnectionProperty(String propertyNameToSet,
String defaultValueToSet, String descriptionToSet,
String sinceVersionToSet, String category, int orderInCategory) {
@@ -900,6 +920,9 @@
+ "(MySQL 4.1.0 and newer)?", "3.1.2", MISC_CATEGORY,
Integer.MIN_VALUE);
+ private boolean jdbcCompliantTruncationForReads =
+ this.jdbcCompliantTruncation.getValueAsBoolean();
+
private MemorySizeConnectionProperty locatorFetchBufferSize = new MemorySizeConnectionProperty(
"locatorFetchBufferSize",
1024 * 1024,
@@ -1399,8 +1422,8 @@
propToExpose.initializeFrom(info);
}
- propToExpose.syncDriverPropertyInfo();
- driverProperties[i] = propToExpose;
+
+ driverProperties[i] = propToExpose.getAsDriverPropertyInfo();
} catch (IllegalAccessException iae) {
throw SQLError.createSQLException("Internal properties failure",
SQLError.SQL_STATE_GENERAL_ERROR);
@@ -1514,7 +1537,6 @@
while (orderedIter.hasNext()) {
ConnectionProperty propToGet = (ConnectionProperty) orderedIter
.next();
- propToGet.syncDriverPropertyInfo();
xmlBuf.append("\n <Property name=\"");
xmlBuf.append(propToGet.getPropertyName());
@@ -1540,7 +1562,6 @@
while (alphaIter.hasNext()) {
ConnectionProperty propToGet = (ConnectionProperty) alphaIter
.next();
- propToGet.syncDriverPropertyInfo();
xmlBuf.append("\n <Property name=\"");
xmlBuf.append(propToGet.getPropertyName());
@@ -3663,4 +3684,13 @@
public int getPrepStmtCacheSqlLimit() {
return getPreparedStatementCacheSqlLimit();
}
+
+ protected boolean getJdbcCompliantTruncationForReads() {
+ return this.jdbcCompliantTruncationForReads;
}
+
+ protected void setJdbcCompliantTruncationForReads(
+ boolean jdbcCompliantTruncationForReads) {
+ this.jdbcCompliantTruncationForReads = jdbcCompliantTruncationForReads;
+ }
+}
| Thread |
|---|
| • Connector/J commit: r5399 - in branches: branch_5_0/connector-j branch_5_0/connector-j/src/com/mysql/jdbc branch_5_1/connector-j branch_5_1/connector-... | mmatthews | 16 Jun |