{"record":{"id":"7efa63ae2d8d723a","repo":"MyCATApache/Mycat-Server","slug":"holdability-not-supported-yet","errorCode":null,"errorMessage":"holdability not supported yet","messagePattern":"holdability not supported yet","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/backend/jdbc/mongodb/MongoStatement.java","lineNumber":40,"sourceCode":"    private int _fetchSize = 0;\n    //int _maxRows = 0;\n    private MongoResultSet _last;\n\n    public MongoStatement(MongoConnection conn, int type, int concurrency, int holdability)\n    {\n        this._conn = conn;\n        this._type = type;\n        this._concurrency = concurrency;\n        this._holdability = holdability;\n\n        if (this._type != 0) {\n\t\t\tthrow new UnsupportedOperationException(\"type not supported yet\");\n\t\t}\n        if (this._concurrency != 0) {\n\t\t\tthrow new UnsupportedOperationException(\"concurrency not supported yet\");\n\t\t}\n        if (this._holdability != 0) {\n\t\t\tthrow new UnsupportedOperationException(\"holdability not supported yet\");\n\t\t}\n    }\n\n\t@Override\n\tpublic <T> T unwrap(Class<T> iface) throws SQLException {\n\t\t\n\t\tthrow new UnsupportedOperationException();//return null;\n\t}\n\n\t@Override\n\tpublic boolean isWrapperFor(Class<?> iface) throws SQLException {\n\t\t\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic ResultSet executeQuery(String sql) throws SQLException {\n\t\t  ","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/backend/jdbc/mongodb/MongoStatement.java#L22-L58","documentation":"MongoStatement validates statement options at creation time and rejects any statement whose holdability is set to a non-zero value. The MongoDB backend does not implement ResultSet holdability semantics (keeping cursors open after commit), so it fails fast with UnsupportedOperationException rather than silently ignoring the setting. The check runs in the public constructor/validation path, so construction itself throws.","triggerScenarios":"Calling Connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability) or prepareStatement overloads with a holdability argument other than 0 when using the MongoDB JDBC driver; passing constants like ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT.","commonSituations":"Application code or ORM/connection-pool configuration (e.g. MyBatis, Hibernate, DBCP statement defaults) specifies a holdability value that works on MySQL/PostgreSQL but is passed through unchanged to the Mycat MongoDB driver; porting JDBC code between backends.","solutions":["Use the holdability-free overloads: Connection.createStatement() or createStatement(resultSetType, resultSetConcurrency) so _holdability stays 0.","Change the caller/configuration to pass 0 (no explicit holdability) when connecting to the MongoDB backend.","Explicitly unset holdability in ORM/datasource settings (e.g. disable resultSetHoldability options in pool/ORM config).","If holdability is truly required, patch MongoStatement to accept and ignore or implement the holdability setting for the MongoDB backend.","Route statements that need holdability to a backend that supports it instead of the MongoDB driver."],"exampleFix":"// before\nStatement st = conn.createStatement(\n    ResultSet.TYPE_FORWARD_ONLY,\n    ResultSet.CONCUR_READ_ONLY,\n    ResultSet.HOLD_CURSORS_OVER_COMMIT);\n// after\nStatement st = conn.createStatement(\n    ResultSet.TYPE_FORWARD_ONLY,\n    ResultSet.CONCUR_READ_ONLY);","handlingStrategy":"try-catch","validationCode":"// check before creating the statement\nif (holdability != 0) {\n    throw new IllegalArgumentException(\n        \"MongoDB backend requires holdability=0, got \" + holdability);\n}\nStatement st = conn.createStatement(type, concurrency /*, no holdability */);","typeGuard":"boolean isMongoBackend(Connection c) {\n    try { return c.getMetaData().getDatabaseProductName().toLowerCase().contains(\"mongo\"); }\n    catch (SQLException e) { return false; }\n}","tryCatchPattern":"Statement st;\ntry {\n    st = conn.createStatement(type, concurrency, holdability);\n} catch (UnsupportedOperationException e) {\n    st = conn.createStatement(type, concurrency); // drop holdability\n}","preventionTips":["Always use the two-argument createStatement/prepareStatement overloads against the MongoDB backend.","Audit ORM and connection-pool configs for explicit holdability settings.","Document that holdability is unsupported in the Mycat MongoDB driver."],"tags":["jdbc","mongodb","unsupported-operation","holdability"],"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"}