apache/seatunnel · error · org.apache.seatunnel.api.table.type.SeaTunnelException
Error to discover tables:
Error message
Error to discover tables:
What it means
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().
Source
Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/source/Db2Dialect.java:101
}
@Override
public ChunkSplitter createChunkSplitter(JdbcSourceConfig sourceConfig) {
return new Db2ChunkSplitter(sourceConfig, this);
}
@Override
public List<TableId> discoverDataCollections(JdbcSourceConfig sourceConfig) {
Db2SourceConfig db2SourceConfig = (Db2SourceConfig) sourceConfig;
try (JdbcConnection jdbcConnection = openJdbcConnection(sourceConfig)) {
List<TableId> tables =
TableDiscoveryUtils.listTables(
jdbcConnection, db2SourceConfig.getTableFilters());
TableDiscoveryUtils.validateExplicitCaptureTables(
db2SourceConfig.getTableList(), tables);
return tables;
} catch (SQLException e) {
throw new SeaTunnelException("Error to discover tables: " + e.getMessage(), e);
}
}
/**
* Converts a SeaTunnel table path to the empty-catalog identifier emitted by Db2 Debezium.
*
* @param tablePath table path from checkpoint schema state
* @return Db2 Debezium table identifier
*/
@Override
public TableId toTableId(TablePath tablePath) {
return new TableId("", tablePath.getSchemaName(), tablePath.getTableName());
}
@Override
public void checkAllTablesEnabledCapture(JdbcConnection jdbcConnection, List<TableId> tableIds)
throws SQLException {
Set<TableId> tables =View on GitHub (pinned to cf67b549a7)
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.
Example fix
// before
tables = dialect.discoverDataCollections();
// after
try {
tables = dialect.discoverDataCollections();
} catch (SeaTunnelException e) {
LOG.error("Table discovery failed: {}", e.getCause() != null ? e.getCause().getMessage() : e.getMessage(), e);
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: verify DB reachable and user can list tables
try (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {
try (ResultSet rs = c.getMetaData().getTables(null, schema, "%", new String[]{"TABLE"})) {
if (!rs.next()) throw new IllegalStateException("No tables visible to user " + user);
}
} catch (SQLException e) {
throw new IllegalStateException("DB2 preflight failed: " + e.getMessage(), e);
} Try / catch
try {
tables = dialect.discoverDataCollections();
} catch (SeaTunnelException e) {
Throwable cause = e.getCause(); // SQLException with SQLSTATE
LOG.error("discover tables failed: {}", cause == null ? e.getMessage() : cause.getMessage(), e);
throw new RuntimeException("Check DB2 connectivity/privileges, see cause", e);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Error to check tables:
- No result returned after running query [%s]
- Failed to discover captured tables for enumerator
- Failed to discover remaining tables to capture
- Failed to split chunks for table " + tableId
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/9bb45a2df81ac970.
Report an issue: GitHub.