{"record":{"id":"90c2f45b6bfb5eab","repo":"apache/seatunnel","slug":"e-getmessage","errorCode":null,"errorMessage":"${e.getMessage()}","messagePattern":"\\$\\{e\\.getMessage\\(\\)\\}","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java","lineNumber":278,"sourceCode":"        return getLsnPosition(record.sourceOffset());\n    }\n\n    public static LsnOffset getLsnPosition(Map<String, ?> offset) {\n        Map<String, String> offsetStrMap = new HashMap<>();\n        for (Map.Entry<String, ?> entry : offset.entrySet()) {\n            offsetStrMap.put(\n                    entry.getKey(), entry.getValue() == null ? null : entry.getValue().toString());\n        }\n        return LsnOffset.valueOf(offsetStrMap);\n    }\n\n    /** Fetch current largest log sequence number (LSN) of the database. */\n    public static LsnOffset currentLsn(Db2Connection connection) {\n        try {\n            Lsn commitLsn = connection.getMaxLsn();\n            return LsnOffset.valueOf(commitLsn.toString());\n        } catch (SQLException e) {\n            throw new SeaTunnelException(e.getMessage(), e);\n        }\n    }\n\n    /** Get split scan query for the given table. */\n    public static String buildSplitScanQuery(\n            TableId tableId, SeaTunnelRowType rowType, boolean isFirstSplit, boolean isLastSplit) {\n        return buildSplitQuery(tableId, rowType, isFirstSplit, isLastSplit, -1, true);\n    }\n\n    /** Get table split data PreparedStatement. */\n    public static PreparedStatement readTableSplitDataStatement(\n            JdbcConnection jdbc,\n            String sql,\n            boolean isFirstSplit,\n            boolean isLastSplit,\n            Object[] splitStart,\n            Object[] splitEnd,\n            SeaTunnelRowType splitKeyType,","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java#L260-L296","documentation":"Db2Utils.currentLsn calls connection.getMaxLsn() to fetch the database's largest log sequence number. On SQLException it wraps the DB2 error message in a SeaTunnelException, so the visible message is whatever DB2 reported (e.g. stored-procedure or connection failure).","triggerScenarios":"getMaxLsn() (which invokes the ASNCDC.ASN_READ_LSN-style access) fails — invalid connection, DB2 CDC service not registered/started, or insufficient privileges to read LSN.","commonSituations":"ASNCDC capture service not started; user lacks authority to execute CDC procedures; network/connection dropped to DB2; database not enabled for CDC.","solutions":["Start the DB2 ASN capture service (CALL ASNCDC.START)","Grant the connector user privileges to read LSN / execute CDC procedures","Check DB2 connectivity and re-run the job","Inspect the wrapped cause message for the actual DB2 error code"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure CDC capture service is up before the source starts\ncall ASNCDC.START; -- and verify IBMSNAP_REGISTER has entries","typeGuard":null,"tryCatchPattern":"try { LsnOffset lsn = Db2Utils.currentLsn(connection); } catch (SeaTunnelException e) { log.error(\"getMaxLsn failed, check capture service/privileges: {}\", e.getMessage()); throw e; }","preventionTips":["Start ASN capture service before running the connector","Grant the connector user authority to read LSN data","Validate DB2 connectivity at job startup"],"tags":["db2","cdc","lsn","sql"],"backgroundTag":"database-query-failed","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"}