{"record":{"id":"6d5ecdcb2cb79c08","repo":"MyCATApache/Mycat-Server","slug":"callablestatement-not-supported","errorCode":null,"errorMessage":"CallableStatement not supported","messagePattern":"CallableStatement not supported","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/backend/jdbc/mongodb/MongoConnection.java","lineNumber":254,"sourceCode":"\tpublic CallableStatement prepareCall(String sql) throws SQLException {\n\t\t\n\t\treturn prepareCall(sql, 0, 0, 0);\n\t}\n\t\n\t@Override\n\tpublic CallableStatement prepareCall(String sql, int resultSetType,\n\t\t\tint resultSetConcurrency) throws SQLException {\n\t\t\n\t\treturn prepareCall(sql, resultSetType, resultSetConcurrency, 0);\n\t}\n\n\t@Override\n\tpublic CallableStatement prepareCall(String sql, int resultSetType,\n\t\t\tint resultSetConcurrency, int resultSetHoldability)\n\t\t\tthrows SQLException {\n\t\t\n\t\t//return null;\n\t\tthrow new RuntimeException(\"CallableStatement not supported\");\n\t}\n\t\n\t@Override\n\tpublic PreparedStatement prepareStatement(String sql) throws SQLException {\n\t\t\n\t\treturn prepareStatement(sql, 0, 0, 0);\n\t}\n\n\t@Override\n\tpublic PreparedStatement prepareStatement(String sql, int resultSetType,\n\t\t\tint resultSetConcurrency) throws SQLException {\n\t\t\n\t\treturn prepareStatement(sql, resultSetType, resultSetConcurrency, 0);\n\t}\n\n\t@Override\n\tpublic PreparedStatement prepareStatement(String sql, int resultSetType,\n\t\t\tint resultSetConcurrency, int resultSetHoldability)","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/backend/jdbc/mongodb/MongoConnection.java#L236-L272","documentation":"MongoConnection.prepareCall unconditionally throws RuntimeException(\"CallableStatement not supported\"). The MongoDB JDBC adapter in MyCat does not implement stored-procedure calls; every overload of prepareCall is a stub. Any code asking this connection for a CallableStatement will always fail.","triggerScenarios":"Calling connection.prepareCall(String), prepareCall(String,int,int), or prepareCall(String,int,int,int) on a MongoConnection obtained via MongoDriver.connect for URL scheme mongodb://.","commonSituations":"Configuring MyCat with a MongoDB backend JDBC node and then running SQL that the MyCat planner routes to a stored-procedure CALL statement; reusing generic JDBC data-access code (e.g. frameworks that probe prepareCall) against a Mongo backend.","solutions":["Do not issue CALL / stored-procedure statements against MongoDB-backed nodes; MongoDB has no stored procedures via this adapter","Restrict prepareCall-based data-access code paths to RDBMS backends and use prepareStatement for Mongo nodes","If you only need it not to crash, wrap the call in try-catch for RuntimeException and fall back to prepareStatement","Patch MongoConnection to throw java.sql.SQLFeatureNotSupportedException instead of RuntimeException so JDBC clients can detect and degrade gracefully"],"exampleFix":"// before\n@Override\npublic CallableStatement prepareCall(String sql, int resultSetType,\n        int resultSetConcurrency, int resultSetHoldability) throws SQLException {\n    throw new RuntimeException(\"CallableStatement not supported\");\n}\n\n// after\n@Override\npublic CallableStatement prepareCall(String sql, int resultSetType,\n        int resultSetConcurrency, int resultSetHoldability) throws SQLException {\n    throw new SQLFeatureNotSupportedException(\"CallableStatement not supported by MongoDB backend\");\n}","handlingStrategy":"try-catch","validationCode":"if (conn instanceof MongoConnection || url.startsWith(\"jdbc:mongodb\")) {\n    throw new UnsupportedOperationException(\"prepareCall is not supported for MongoDB backends; use prepareStatement\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    CallableStatement cs = conn.prepareCall(sql);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"CallableStatement not supported\")) {\n        // fall back to PreparedStatement-based execution\n    } else {\n        throw e;\n    }\n}","preventionTips":["Never route CALL/stored-procedure statements to MongoDB data nodes","Gate prepareCall usage behind a backend-capability check (URL scheme or connection class)","Prefer checking DatabaseMetaData supportsStoredProcedures() before calling prepareCall"],"tags":["jdbc","mongodb","unsupported-operation","callablestatement"],"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"}