{"record":{"id":"a58377c01b221df7","repo":"apache/shardingsphere","slug":"unsupported-conversion-data-type-s-for-value","errorCode":null,"errorMessage":"Unsupported conversion data type '%s' for value '%s'.","messagePattern":"Unsupported conversion data type '(.+?)' for value '(.+?)'\\.","errorType":"exception","errorClass":"UnsupportedDataTypeConversionException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/MySQLResultSetValueConverter.java","lineNumber":86,"sourceCode":"                case \"java.math.BigDecimal\":\n                    return stringValue.isEmpty() ? BigDecimal.ZERO : convertNumericValue(stringValue, convertType);\n                default:\n                    return ResultSetUtils.convertValue(value, convertType);\n            }\n        } catch (final NumberFormatException | ArithmeticException ignored) {\n            throw new UnsupportedDataTypeConversionException(convertType, value);\n        }\n    }\n    \n    @Override\n    public String getType() {\n        return \"MySQL\";\n    }\n    \n    private byte convertByteValue(final String value, final Class<?> convertType) {\n        byte[] bytes = value.getBytes(StandardCharsets.UTF_8);\n        if (1 != bytes.length) {\n            throw new UnsupportedDataTypeConversionException(convertType, value);\n        }\n        return bytes[0];\n    }\n    \n    private Boolean convertBooleanValue(final String value, final Class<?> convertType) {\n        if (\"Y\".equalsIgnoreCase(value) || \"yes\".equalsIgnoreCase(value) || \"T\".equalsIgnoreCase(value) || \"true\".equalsIgnoreCase(value)) {\n            return true;\n        }\n        if (\"N\".equalsIgnoreCase(value) || \"no\".equalsIgnoreCase(value) || \"F\".equalsIgnoreCase(value) || \"false\".equalsIgnoreCase(value)) {\n            return false;\n        }\n        if (value.contains(\"e\") || value.contains(\"E\") || FLOATING_POINT_PATTERN.matcher(value).matches()) {\n            return convertDoubleToBoolean(Double.parseDouble(value));\n        }\n        if (INTEGER_PATTERN.matcher(value).matches()) {\n            return isSignedLong(value) ? longToBoolean(Long.parseLong(value)) : convertBigIntegerToBoolean(new BigInteger(value));\n        }\n        throw new UnsupportedDataTypeConversionException(convertType, value);","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/MySQLResultSetValueConverter.java#L68-L104","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nbyte b = rs.getByte(\"FLAG\"); // FLAG = \"42\"\n// after\nint b = rs.getInt(\"FLAG\");","handlingStrategy":"validation","validationCode":"String s = rs.getString(col);\nif (s == null || s.getBytes(UTF_8).length != 1) doNotCallGetByte();","typeGuard":"boolean isSingleAsciiByte(String s) { return s != null && s.length() == 1 && s.charAt(0) < 128; }","tryCatchPattern":"catch (UnsupportedDataTypeConversionException ex) { use getInt/getString instead; }","preventionTips":["getByte here means one character's byte, not a parsed number","Use getInt for numeric columns","Keep single-char flag columns exactly one character"],"tags":["jdbc","type-conversion","mysql","byte"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}