apache/seatunnel · error · CatalogException
查询数据库是否存在失败:
Error message
查询数据库是否存在失败:
What it means
KingbaseCatalog.databaseExists wraps any SQLException from the database-existence query into CatalogException("查询数据库是否存在失败: <databaseName>") ("Failed to check whether database exists"). The concrete JDBC error is the chained cause.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/kingbase/KingbaseCatalog.java:158
* Override the databaseExists method because SELECT current_database() does not support WHERE
*/
@Override
public boolean databaseExists(String databaseName) throws CatalogException {
if (StringUtils.isBlank(databaseName)) {
return false;
}
try {
return querySQLResultExists(getUrlFromDatabaseName(databaseName), getListDatabaseSql());
} catch (SeaTunnelRuntimeException e) {
if (e.getSeaTunnelErrorCode().getCode().equals(UNSUPPORTED_METHOD.getCode())) {
log.warn(
"The catalog: {} is not supported the getListDatabaseSql for databaseExists",
this.catalogName);
return listDatabases().contains(databaseName);
}
throw e;
} catch (SQLException e) {
throw new CatalogException("查询数据库是否存在失败: " + databaseName, e);
}
}
@Override
protected String getCreateTableSql(
TablePath tablePath, CatalogTable table, boolean createIndex) {
return new KingbaseCreateTableSqlBuilder(table, createIndex).build(tablePath);
}
@Override
protected String getDropTableSql(TablePath tablePath) {
return String.format("DROP TABLE %s", tablePath.getSchemaAndTableName("\""));
}
@Override
protected String getListTableSql(String databaseName) {
return "SELECT SCHEMANAME ,TABLENAME FROM SYS_TABLES";
}View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the chained cause (getCause) for the underlying SQLException
- Verify connectivity/credentials to the Kingbase server with a standalone JDBC client
- Confirm the database name is valid and properly escaped
- Check the Kingbase version supports the SQL used by getListDatabaseSql / existence query
- Grant the catalog user permission to read system catalogs (e.g. pg_database equivalents)
Example fix
// before
boolean exists = catalog.databaseExists(dbName); // CatalogException with Chinese msg
// after
try {
boolean exists = catalog.databaseExists(dbName);
} catch (CatalogException e) {
LOG.error("databaseExists {} failed: {}", dbName, e.getCause());
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
try (Connection c = DriverManager.getConnection(kingbaseUrl, user, pass)) {
if (!c.isValid(5)) throw new IllegalStateException("Kingbase connection invalid");
} Try / catch
try {
boolean exists = catalog.databaseExists(dbName);
} catch (CatalogException e) {
LOG.error("Kingbase databaseExists({}) failed: {}", dbName, e.getCause(), e);
throw e;
} Prevention
- Inspect getCause() — the top message is a localized generic string
- Verify Kingbase connectivity and credentials before catalog calls
- Grant the catalog user read access to system catalogs
- Escape/validate database names with special characters
When it happens
Trigger: Calling databaseExists(name) (directly or via framework pre-checks) when the SQL query against the Kingbase server throws SQLException: server unreachable, wrong credentials, invalid database name characters, or the existence-check SQL is unsupported by the Kingbase version.
Common situations: Kingbase (人大金仓) server down or wrong port; user lacking privileges to query system databases; database name with special characters breaking the query; Kingbase version whose system catalog differs from the assumed SQL.
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 executeSql error %s
- Failed dropping table %s
- Failed creating database %s in catalog %s
- Failed dropping database %s in catalog %s
- Failed truncate table %s in catalog %s
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/dec71460f4484c23.
Report an issue: GitHub.