{"record":{"id":"9bb45a2df81ac970","repo":"apache/seatunnel","slug":"error-to-discover-tables","errorCode":null,"errorMessage":"Error to discover tables: ","messagePattern":"Error to discover tables: ","errorType":"exception","errorClass":"org.apache.seatunnel.api.table.type.SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/source/Db2Dialect.java","lineNumber":101,"sourceCode":"    }\n\n    @Override\n    public ChunkSplitter createChunkSplitter(JdbcSourceConfig sourceConfig) {\n        return new Db2ChunkSplitter(sourceConfig, this);\n    }\n\n    @Override\n    public List<TableId> discoverDataCollections(JdbcSourceConfig sourceConfig) {\n        Db2SourceConfig db2SourceConfig = (Db2SourceConfig) sourceConfig;\n        try (JdbcConnection jdbcConnection = openJdbcConnection(sourceConfig)) {\n            List<TableId> tables =\n                    TableDiscoveryUtils.listTables(\n                            jdbcConnection, db2SourceConfig.getTableFilters());\n            TableDiscoveryUtils.validateExplicitCaptureTables(\n                    db2SourceConfig.getTableList(), tables);\n            return tables;\n        } catch (SQLException e) {\n            throw new SeaTunnelException(\"Error to discover tables: \" + e.getMessage(), e);\n        }\n    }\n\n    /**\n     * Converts a SeaTunnel table path to the empty-catalog identifier emitted by Db2 Debezium.\n     *\n     * @param tablePath table path from checkpoint schema state\n     * @return Db2 Debezium table identifier\n     */\n    @Override\n    public TableId toTableId(TablePath tablePath) {\n        return new TableId(\"\", tablePath.getSchemaName(), tablePath.getTableName());\n    }\n\n    @Override\n    public void checkAllTablesEnabledCapture(JdbcConnection jdbcConnection, List<TableId> tableIds)\n            throws SQLException {\n        Set<TableId> tables =","sourceCodeStart":83,"sourceCodeEnd":119,"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/source/Db2Dialect.java#L83-L119","documentation":"Db2Dialect.discoverDataCollections() wraps any SQLException thrown while listing capture-enabled tables via TableDiscoveryUtils.listTables() into a SeaTunnelException with the message \"Error to discover tables: <sql message>\". It means the JDBC query used to enumerate tables in the Db2 CDC source failed, so the connector cannot determine which tables to capture. The root cause is always in the wrapped SQLException, accessible via getCause().","triggerScenarios":"Calling discoverDataCollections() (invoked during source split enumeration when a Db2 CDC job starts) and the underlying JDBC query that lists tables throws a SQLException — e.g. connection dropped, bad credentials, database down, or query timeout.","commonSituations":"Db2 database unreachable or restarted mid-job; wrong username/password or insufficient privileges to read the catalog tables; network/firewall blocking the JDBC port; TLS mismatch between driver and server; connection pool exhausted.","solutions":["Inspect the cause: log or print e.getCause() (the original SQLException) — its message and SQLSTATE identify the real problem.","Verify JDBC connectivity from the SeaTunnel node: try connecting with a Db2 client or a plain JDBC test using the same URL/credentials.","Check the Db2 server is running and reachable (port, firewall, hostname resolution).","Confirm the CDC user has permission to read system catalog tables (SYSCAT.TABLES etc.).","If it is a transient network failure, retry the job after restoring connectivity."],"exampleFix":"// before\ntables = dialect.discoverDataCollections();\n// after\ntry {\n    tables = dialect.discoverDataCollections();\n} catch (SeaTunnelException e) {\n    LOG.error(\"Table discovery failed: {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage(), e);\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: verify DB reachable and user can list tables\ntry (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {\n    try (ResultSet rs = c.getMetaData().getTables(null, schema, \"%\", new String[]{\"TABLE\"})) {\n        if (!rs.next()) throw new IllegalStateException(\"No tables visible to user \" + user);\n    }\n} catch (SQLException e) {\n    throw new IllegalStateException(\"DB2 preflight failed: \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    tables = dialect.discoverDataCollections();\n} catch (SeaTunnelException e) {\n    Throwable cause = e.getCause(); // SQLException with SQLSTATE\n    LOG.error(\"discover tables failed: {}\", cause == null ? e.getMessage() : cause.getMessage(), e);\n    throw new RuntimeException(\"Check DB2 connectivity/privileges, see cause\", e);\n}","preventionTips":["Run a JDBC connectivity/privilege preflight before submitting the CDC job.","Monitor DB2 availability and network path from SeaTunnel nodes.","Validate credentials and grants for the CDC user against catalog tables.","Keep checkpointing enabled so transient failures can be retried."],"tags":["db2","cdc","jdbc","sql","table-discovery"],"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-14T05:17:10.506Z"}