{"record":{"id":"a15c0d4ffada19b3","repo":"pinpoint-apm/pinpoint","slug":"unsupportedoperationexception","errorCode":null,"errorMessage":"UnsupportedOperationException","messagePattern":"UnsupportedOperationException","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"commons-mybatis/src/main/java/com/navercorp/pinpoint/mybatis/plugin/PreparedStatementParameterLogger.java","lineNumber":493,"sourceCode":"\n    @Override\n    public int[] executeBatch() throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public Connection getConnection() throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public boolean getMoreResults(int current) throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public ResultSet getGeneratedKeys() throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public int executeUpdate(String sql, String[] columnNames) throws SQLException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-mybatis/src/main/java/com/navercorp/pinpoint/mybatis/plugin/PreparedStatementParameterLogger.java#L475-L511","documentation":"PreparedStatementParameterLogger is a JDBC PreparedStatement wrapper that only logs SQL parameters; it delegates the actual execution to an underlying statement. Statements that do not make sense for a prepared statement being parameter-logged — like getGeneratedKeys() — are hardcoded to throw UnsupportedOperationException.","triggerScenarios":"Calling getGeneratedKeys() on a PreparedStatement wrapped by the parameter logger, typically when using IDENTITY/auto-generated key retrieval through code instrumented by this plugin.","commonSituations":"MyBatis/DAO code using useGeneratedKeys or Statement.RETURN_GENERATED_KEYS while the Pinpoint mybatis plugin wraps the statement for logging; retrieving auto-generated IDs inside an instrumented path.","solutions":["Obtain generated keys from the unwrapped, original PreparedStatement (unwrap or keep a reference before wrapping).","Restructure the code so key retrieval does not pass through the parameter-logging wrapper.","If this blocks a use case, fall back to selecting the generated key with an explicit query (e.g. LAST_INSERT_ID) rather than getGeneratedKeys()."],"exampleFix":"// before\nResultSet keys = loggingStatement.getGeneratedKeys();\n// after\nPreparedStatement raw = loggingStatement.unwrap(PreparedStatement.class);\nResultSet keys = raw.getGeneratedKeys();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    keys = stmt.getGeneratedKeys();\n} catch (UnsupportedOperationException e) {\n    PreparedStatement raw = stmt.unwrap(PreparedStatement.class);\n    keys = raw.getGeneratedKeys();\n}","preventionTips":["Do not call getGeneratedKeys() through the parameter-logging wrapper.","Keep a reference to the original PreparedStatement for key retrieval.","Know which statement methods the wrapper delegates vs. rejects."],"tags":["java","jdbc","mybatis","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}