{"record":{"id":"9d163628ff6faff8","repo":"MyCATApache/Mycat-Server","slug":"unsupport-bindvalue-value","errorCode":null,"errorMessage":"unsupport ${bindValue.value}","messagePattern":"unsupport (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/server/handler/ServerPrepareHandler.java","lineNumber":284,"sourceCode":"                        case Fields.FIELD_TYPE_DATE:\n                        case Fields.FIELD_TYPE_DATETIME:\n                        case Fields.FIELD_TYPE_TIMESTAMP:\n                            o = bindValue.value;\n                            break;\n                        default:\n                            if (bindValue.value instanceof byte[]) {\n                                SQLReplaceable parent = (SQLReplaceable) x.getParent();\n                                byte[] bytes = (byte[]) bindValue.value;\n                                parent.replace(x, new SQLCharExpr(new String(bytes)));\n                                return false;\n                            }\n                            if (bindValue.value instanceof String) {\n                                SQLReplaceable parent = (SQLReplaceable) x.getParent();\n                                String value = (String) bindValue.value;\n                                parent.replace(x, new SQLCharExpr(value));\n                                return false;\n                            }\n                            throw new UnsupportedOperationException(\"unsupport \" + bindValue.value);\n                    }\n\n                    SQLReplaceable parent = (SQLReplaceable) x.getParent();\n                    parent.replace(x, SQLExprUtils.fromJavaObject(o));\n                    return false;\n                }\n            }\n\n        });\n        return sqlStatement.toString();\n    }\n}","sourceCodeStart":266,"sourceCodeEnd":296,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/server/handler/ServerPrepareHandler.java#L266-L296","documentation":"ServerPrepareHandler.visit performs server-side parameter substitution for prepared statements. When a bind value's type is not supported for in-place SQL replacement (the code only handles String values via SQLCharExpr before falling back to SQLExprUtils.fromJavaObject), it throws UnsupportedOperationException naming the unsupported bind value.","triggerScenarios":"Using COM_STMT_EXECUTE / prepared-statement execution where the bound parameter value is of a Java type the visitor cannot convert into a SQL expression (e.g. unusual object types from client bind payloads).","commonSituations":"Drivers sending non-standard bind types; Mycat's prepare handler lacking support for a type supported by real MySQL; passing byte arrays or temporal types through the prepared-statement path.","solutions":["Convert the parameter to a supported type (e.g. String) on the client, or cast it in SQL.","Use text protocol (non-prepared) execution instead of COM_STMT_EXECUTE if the driver allows it.","Patch ServerPrepareHandler.visit to handle the specific value type via SQLExprUtils.fromJavaObject.","Upgrade Mycat to a version with broader prepared-statement type support."],"exampleFix":"// before\nps.setObject(1, new byte[]{1,2});\n// after\nps.setString(1, new String(new byte[]{1,2}));","handlingStrategy":"try-catch","validationCode":"// check bind value types before prepare/execute\nfor (Object v : bindValues) {\n    if (!(v instanceof String || v instanceof Number || v instanceof java.util.Date || v == null))\n        throw new IllegalArgumentException(\"unsupported bind type: \" + v.getClass());\n}","typeGuard":"// java\nstatic boolean isSupportedBindValue(Object v) {\n    return v == null || v instanceof String || v instanceof Number || v instanceof Boolean || v instanceof java.util.Date || v instanceof byte[];\n}","tryCatchPattern":"try { executePrepared(stmt, bindValues); } catch (UnsupportedOperationException e) { log.warn(\"unsupported bind value, falling back to text protocol\", e); executeTextProtocol(sql, bindValues); }","preventionTips":["Bind only primitives, String, Date, and byte[] values.","Prefer text protocol against Mycat for exotic types.","Keep Mycat updated for improved prepared-statement support."],"tags":["prepared-statement","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}