apache/seatunnel · error · CatalogException
Failed executeSql error %s
Error message
Failed executeSql error %s
What it means
executeSql wraps any SQLException raised while preparing or executing the caller-supplied SQL in a CatalogException with message 'Failed executeSql error <sql>'. It signals the statement failed at the database level; the original SQLException is the cause.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java:718
}
}
protected String getTruncateTableSql(TablePath tablePath) {
throw new UnsupportedOperationException();
}
protected String getExistDataSql(TablePath tablePath) {
throw new UnsupportedOperationException();
}
public void executeSql(TablePath tablePath, String sql) {
String dbUrl = getUrlFromDatabaseName(tablePath.getDatabaseName());
Connection connection = getConnection(dbUrl);
try (PreparedStatement ps = connection.prepareStatement(sql)) {
// Will there exist concurrent drop for one table?
ps.execute();
} catch (SQLException e) {
throw new CatalogException(String.format("Failed executeSql error %s", sql), e);
}
}
public boolean isExistsData(TablePath tablePath) {
String dbUrl = getUrlFromDatabaseName(tablePath.getDatabaseName());
Connection connection = getConnection(dbUrl);
String sql = getExistDataSql(tablePath);
try (PreparedStatement ps = connection.prepareStatement(sql);
ResultSet resultSet = ps.executeQuery()) {
return resultSet.next();
} catch (SQLException e) {
throw new CatalogException(String.format("Failed executeSql error %s", sql), e);
}
}
@Override
public PreviewResult previewAction(View on GitHub (pinned to cf67b549a7)
Solutions
- Read the cause SQLException for the database-side error message and fix the SQL syntax or referenced objects
- Verify the database name in tablePath maps to the correct JDBC URL (getUrlFromDatabaseName)
- Check the connected user has privileges to execute the statement
- Test the SQL directly against the database with a client before running it through the catalog
Example fix
// before
catalog.executeSql(tablePath, "TRUNCATE TABLE wrong_schema.t");
// after
catalog.executeSql(TablePath.of("db", "schema", "t"), "TRUNCATE TABLE \"schema\".\"t\""); Defensive patterns
Strategy: try-catch
Validate before calling
// Java
// Validate SQL and target database before executing
Objects.requireNonNull(sql, "sql must not be null");
if (!catalog.databaseExists(tablePath.getDatabaseName())) {
throw new IllegalStateException("Database missing: " + tablePath.getDatabaseName());
} Try / catch
// Java
try {
catalog.executeSql(tablePath, sql);
} catch (CatalogException e) {
Throwable cause = e.getCause(); // java.sql.SQLException with DB-side detail
LOG.error("executeSql failed for [{}]: {}", sql, cause.getMessage(), cause);
} Prevention
- Test the exact SQL against the database with a client before wiring it into the catalog
- Verify getUrlFromDatabaseName maps database names to the intended JDBC URL
- Ensure the catalog user has privileges for the statements you execute
- Log e.getCause() — the SQLException contains the actionable database error
When it happens
Trigger: Calling catalog.executeSql(tablePath, sql) where the SQL has a syntax error, references a nonexistent table/schema, the connection is broken, or the user lacks privileges to execute the statement.
Common situations: Hand-written DDL with a typo; executing DDL on the wrong database URL (getUrlFromDatabaseName resolves the wrong host); insufficient grants; transient network failures mid-statement.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- Failed to split chunks for table " + tableId
- Error to discover tables:
- Error to check tables:
- No result returned after running query [%s]
- Unexpected error while connecting to MySQL and looking at GT
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/ad1053dd025e0dee.
Report an issue: GitHub.