{"record":{"id":"f64dfb2cd061c7ce","repo":"apache/seatunnel","slug":"jdbcconnectorerrorcode-data-type-cast-failed","errorCode":"JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED","errorMessage":"error field:${fieldName}","messagePattern":"error field:(.+?)","errorType":"error_code","errorClass":"JdbcConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oceanbase/OceanBaseMysqlJdbcRowConverter.java","lineNumber":271,"sourceCode":"                        if (SqlType.TINYINT.equals(elementType.getSqlType())) {\n                            Short[] shortArray = new Short[array.length];\n                            for (int i = 0; i < array.length; i++) {\n                                shortArray[i] = Short.valueOf(array[i].toString());\n                            }\n                            statement.setObject(statementIndex, shortArray);\n                        } else {\n                            statement.setObject(statementIndex, array);\n                        }\n                        break;\n                    case MAP:\n                    case ROW:\n                    default:\n                        throw new JdbcConnectorException(\n                                CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,\n                                \"Unexpected value: \" + seaTunnelDataType);\n                }\n            } catch (Exception e) {\n                throw new JdbcConnectorException(\n                        JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED,\n                        \"error field:\" + rowType.getFieldNames()[fieldIndex],\n                        e);\n            }\n        }\n        return statement;\n    }\n}\n","sourceCodeStart":253,"sourceCodeEnd":280,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oceanbase/OceanBaseMysqlJdbcRowConverter.java#L253-L280","documentation":"OceanBaseMysqlJdbcRowConverter.toExternal wraps any exception raised while setting a field on the PreparedStatement and rethrows it as JdbcConnectorException with DATA_TYPE_CAST_FAILED, identifying the failing field name. It indicates the SeaTunnel value could not be converted/bound to the target JDBC column type.","triggerScenarios":"During toExternal, converting a field value (rowType.getFieldNames()[fieldIndex]) throws — e.g. a String that is not a valid number for an INT column, an out-of-range value for the column type, or an incompatible object passed to a setter.","commonSituations":"Source data contains values that don't fit the OceanBase column types (oversized numbers, bad date strings); a cast rule mismatch between source schema and table schema; nulls handled where the converter expects a value.","solutions":["Fix the field named in the message: align source schema type with the OceanBase column type.","Insert a transform to cast/cleanse the offending field before the sink.","Alter the table column to a type that can hold the source values (e.g. BIGINT/DECIMAL, wider VARCHAR).","Inspect the cause exception (wrapped as cause) for the exact conversion failure."],"exampleFix":"// before\nsource field: age STRING (\"thirty\") -> column age INT\n// after\nTransform: cast(age as INT) with validation/default, or change column to VARCHAR","handlingStrategy":"validation","validationCode":"// Validate value fits target column before writing\nif (value instanceof String && targetColumnIsNumeric) {\n    Long.parseLong((String) value); // throws early with field context\n}","typeGuard":null,"tryCatchPattern":"catch (JdbcConnectorException e) { if (e.getSeaTunnelApiErrorCode() == JdbcConnectorErrorCode.DATA_TYPE_CAST_FAILED) { log.error(\"Cast failed for field {}\", e.getMessage()); } }","preventionTips":["Align source field types with OceanBase column types in the catalog","Add transform casts/cleansing for mismatched fields before the sink","Check the wrapped cause exception for the exact conversion problem"],"tags":["jdbc","oceanbase","type-cast","data-conversion"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}