{"record":{"id":"1334b0a2b98ee1c4","repo":"apache/seatunnel","slug":"error-to-discover-tables-e-getmessage-1334b0","errorCode":null,"errorMessage":"Error to discover tables: ${e.getMessage()}","messagePattern":"Error to discover tables: (.+?)","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/source/SqlServerDialect.java","lineNumber":101,"sourceCode":"                sourceConfig.getDbzConfiguration());\n    }\n\n    @Override\n    public ChunkSplitter createChunkSplitter(JdbcSourceConfig sourceConfig) {\n        return new SqlServerChunkSplitter(sourceConfig, this);\n    }\n\n    @Override\n    public List<TableId> discoverDataCollections(JdbcSourceConfig sourceConfig) {\n        SqlServerSourceConfig sqlServerSourceConfig = (SqlServerSourceConfig) sourceConfig;\n        try (JdbcConnection jdbcConnection = openJdbcConnection(sourceConfig)) {\n            List<TableId> tables =\n                    TableDiscoveryUtils.listTables(\n                            jdbcConnection, sqlServerSourceConfig.getTableFilters());\n            this.checkAllTablesEnabledCapture(jdbcConnection, tables);\n            return tables;\n        } catch (SQLException e) {\n            throw new SeaTunnelException(\"Error to discover tables: \" + e.getMessage(), e);\n        }\n    }\n\n    @Override\n    public void checkAllTablesEnabledCapture(JdbcConnection jdbcConnection, List<TableId> tableIds)\n            throws SQLException {\n        Map<String, List<TableId>> databases =\n                tableIds.stream()\n                        .collect(Collectors.groupingBy(TableId::catalog, Collectors.toList()));\n        for (String database : databases.keySet()) {\n            Set<TableId> tables =\n                    ((SqlServerConnection) jdbcConnection)\n                            .getChangeTables(database).stream()\n                                    .map(SqlServerChangeTable::getSourceTableId)\n                                    .collect(Collectors.toSet());\n            for (TableId tableId : databases.get(database)) {\n                if (!tables.contains(tableId)) {\n                    throw new SeaTunnelException(","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/source/SqlServerDialect.java#L83-L119","documentation":"Thrown by SqlServerDialect.discoverDataCollections() when listing tables or verifying their CDC capture status throws a SQLException. It wraps the driver error into a SeaTunnelException reporting 'Error to discover tables'.","triggerScenarios":"TableDiscoveryUtils.listTables(jdbcConnection, tableFilters) or checkAllTablesEnabledCapture hits a SQLException — connection failure, permission denial on the catalog, or query timeout against sys.tables / change tables.","commonSituations":"SQL Server unreachable (wrong host/port, firewall); login lacking catalog read permission; database name misspelled in config; transient network blips during job startup.","solutions":["Verify connectivity: host, port, database name, and login credentials in the source config","Grant the login permission to read catalog views (VIEW DEFINITION / db_datareader)","Check the wrapped SQLException cause for the precise driver message","Retry on transient failures; enable connection retry/timeouts","Confirm the database is a full (not partial) recovery model with CDC reachable"],"exampleFix":"// before\n// no preflight check\ndialect.discoverDataCollections(config);\n// after\ntry (JdbcConnection c = dialect.openJdbcConnection(config)) {\n    c.connection().isValid(10); // fail early with a clearer error\n}\ndialect.discoverDataCollections(config);","handlingStrategy":"validation","validationCode":"-- preflight: all configured tables exist and are CDC-enabled\nSELECT t.name FROM sys.tables t\nJOIN sys.databases d ON d.is_cdc_enabled = 1\nWHERE t.name IN ('table1','table2');\n-- and per table: SELECT * FROM sys.cdc_change_tables WHERE source_object = N'table1';","typeGuard":null,"tryCatchPattern":"try {\n    tables = dialect.discoverDataCollections(config);\n} catch (SeaTunnelException e) {\n    if (e.getCause() instanceof SQLException s && \"08001\".equals(s.getSQLState())) {\n        // transient connectivity — retry with backoff\n    }\n    throw e;\n}","preventionTips":["Run a connectivity preflight (host/port/db/user/password) before job start","Enable CDC on every table matched by the table-names filter","Grant catalog-read permissions to the connector login","Configure JDBC connect/socket timeouts with retries"],"tags":["sqlserver","cdc","jdbc","table-discovery"],"backgroundTag":"sql-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"}