apache/shardingsphere · error · UnsupportedDataTypeConversionException
Unsupported conversion data type '%s' for value '%s'.
Error message
Unsupported conversion data type '%s' for value '%s'.
What it means
UnsupportedDataTypeConversionException from MySQLResultSetValueConverter.convertByteValue: the value's UTF-8 bytes must be exactly 1 byte long to convert to a byte; any other length (empty string, multi-byte character, multi-char text) throws. This enforces MySQL's single-character TINYINT/BYTE coercion semantics.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/MySQLResultSetValueConverter.java:86
case "java.math.BigDecimal":
return stringValue.isEmpty() ? BigDecimal.ZERO : convertNumericValue(stringValue, convertType);
default:
return ResultSetUtils.convertValue(value, convertType);
}
} catch (final NumberFormatException | ArithmeticException ignored) {
throw new UnsupportedDataTypeConversionException(convertType, value);
}
}
@Override
public String getType() {
return "MySQL";
}
private byte convertByteValue(final String value, final Class<?> convertType) {
byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
if (1 != bytes.length) {
throw new UnsupportedDataTypeConversionException(convertType, value);
}
return bytes[0];
}
private Boolean convertBooleanValue(final String value, final Class<?> convertType) {
if ("Y".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value) || "T".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value)) {
return true;
}
if ("N".equalsIgnoreCase(value) || "no".equalsIgnoreCase(value) || "F".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) {
return false;
}
if (value.contains("e") || value.contains("E") || FLOATING_POINT_PATTERN.matcher(value).matches()) {
return convertDoubleToBoolean(Double.parseDouble(value));
}
if (INTEGER_PATTERN.matcher(value).matches()) {
return isSignedLong(value) ? longToBoolean(Long.parseLong(value)) : convertBigIntegerToBoolean(new BigInteger(value));
}
throw new UnsupportedDataTypeConversionException(convertType, value);View on GitHub (pinned to e952770a21)
Solutions
- Use getInt/getLong/getBigDecimal for numeric columns instead of getByte.
- If the column is a single-character flag, ensure stored values are exactly one character and non-empty (trim on write).
- Read with getString and convert explicitly with your own validation.
Example fix
// before
byte b = rs.getByte("FLAG"); // FLAG = "42"
// after
int b = rs.getInt("FLAG"); Defensive patterns
Strategy: validation
Validate before calling
String s = rs.getString(col); if (s == null || s.getBytes(UTF_8).length != 1) doNotCallGetByte();
Type guard
boolean isSingleAsciiByte(String s) { return s != null && s.length() == 1 && s.charAt(0) < 128; } Try / catch
catch (UnsupportedDataTypeConversionException ex) { use getInt/getString instead; } Prevention
- getByte here means one character's byte, not a parsed number
- Use getInt for numeric columns
- Keep single-char flag columns exactly one character
When it happens
Trigger: Calling getByte on a column whose string value is not exactly one character — e.g. '42', 'Y ', '', or a multi-byte Unicode character — routed through the MySQL converter.
Common situations: Assuming getByte parses numbers (it does not here — it takes a single character's byte value); trailing whitespace or empty strings in char columns; multi-byte UTF-8 content; reading flags stored as words ('yes') instead of single chars.
Related errors
- 0
- Can not support date format if year, month, day is absent.
- 0
- getObject with type
- Can not support type `%s`.
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/a58377c01b221df7.
Report an issue: GitHub.