Modified:
branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
Log:
Fixups for number parsing for JDK-6.0 and beyond.
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-03-09 21:20:37
UTC (rev 5038)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2006-03-09 21:27:40
UTC (rev 5039)
@@ -1541,9 +1541,20 @@
return (byte) convertToZeroWithEmptyCheck();
}
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ stringVal = stringVal.trim();
+
try {
int decimalIndex = stringVal.indexOf(".");
+
if (decimalIndex != -1) {
double valueAsDouble = Double.parseDouble(stringVal);
@@ -1915,7 +1926,19 @@
this.wasNullFlag = true;
return null;
- } else if (stringVal.equals("0") || stringVal.equals("0000-00-00")
+ }
+
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ stringVal = stringVal.trim();
+
+ if (stringVal.equals("0") || stringVal.equals("0000-00-00")
|| stringVal.equals("0000-00-00 00:00:00")
|| stringVal.equals("00000000000000")
|| stringVal.equals("0")) {
@@ -2438,6 +2461,16 @@
if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
&& (val.indexOf(".") == -1)) {
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ val = val.trim();
+
int valueAsInt = Integer.parseInt(val);
if (this.connection.getJdbcCompliantTruncation()) {
@@ -5517,7 +5550,19 @@
this.wasNullFlag = true;
return null;
- } else if (timeAsString.equals("0")
+ }
+
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ timeAsString = timeAsString.trim();
+
+ if (timeAsString.equals("0")
|| timeAsString.equals("0000-00-00")
|| timeAsString.equals("0000-00-00 00:00:00")
|| timeAsString.equals("00000000000000")) {
@@ -5758,6 +5803,16 @@
return null;
}
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ timestampValue = timestampValue.trim();
+
int length = timestampValue.length();
Calendar sessionCalendar = this.connection.getUseJDBCCompliantTimezoneShift() ?
@@ -6516,6 +6571,16 @@
if (valueAsBytes != null) {
intValue = StringUtils.getInt(valueAsBytes);
} else {
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ valueAsString = valueAsString.trim();
+
intValue = Integer.parseInt(valueAsString);
}
@@ -6568,6 +6633,16 @@
if (valueAsBytes != null) {
longValue = StringUtils.getLong(valueAsBytes);
} else {
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ valueAsString = valueAsString.trim();
+
longValue = Long.parseLong(valueAsString);
}
@@ -6622,6 +6697,16 @@
if (valueAsBytes != null) {
shortValue = StringUtils.getShort(valueAsBytes);
} else {
+ //
+ // JDK-6 doesn't like trailing whitespace
+ //
+ // Note this isn't a performance issue, other
+ // than the iteration over the string, as String.trim()
+ // will return a new string only if whitespace is present
+ //
+
+ valueAsString = valueAsString.trim();
+
shortValue = Short.parseShort(valueAsString);
}
| Thread |
|---|
| • Connector/J commit: r5039 - branches/branch_5_0/connector-j/src/com/mysql/jdbc | mmatthews | 9 Mar |