OtterMind/Chat2DB · error · BusinessException

database.delete.notSupportSchema

database.delete.notSupportSchema

Error message

database.delete.notSupportSchema

What it means

Thrown by MysqlDBManager.dropSchema because MySQL has no separate schema concept: a MySQL 'schema' is synonymous with a database. The method unconditionally throws BusinessException('database.delete.notSupportSchema') to signal the operation is not applicable to this dialect. The frontend should route schema-level deletes to dropDatabase for MySQL connections.

Source

Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-mysql/src/main/java/ai/chat2db/plugin/mysql/MysqlDBManager.java:235

        if (StringUtils.isEmpty(database)) {
            return;
        }
        try {
            DefaultSQLExecutor.getInstance().execute(connection, String.format(SQL_SELECT_DATABASE_TEMPLATE, format(database)));
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }


    @Override
    public void dropDatabase(Connection connection, String databaseName) {
        executeDropSql(connection, new MysqlSqlBuilder().ddl().database().buildDropDatabase(databaseName));
    }

    @Override
    public void dropSchema(Connection connection, String databaseName, String schemaName) {
        throw new BusinessException("database.delete.notSupportSchema");
    }

    void executeDropSql(Connection connection, String sql) {
        DefaultSQLExecutor.getInstance().execute(connection, sql, resultSet -> null);
    }

    @Override
    public String dropTable(Connection connection, String databaseName, String schemaName, String tableName) {
        return String.format(SQL_DROP_TABLE_TEMPLATE, format(tableName));
    }

    @Override
    public String truncateTable(Connection connection, String databaseName, String schemaName, String tableName) {
        return String.format(SQL_TRUNCATE_TABLE_TEMPLATE, format(tableName));
    }

    @Override
    public void copyTable(Connection connection, String databaseName, String schemaName, String tableName, String newTableName, boolean copyData) {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Gate dropSchema calls behind a dialect capability check: on MySQL, call dropDatabase instead and do not call dropSchema.
  2. Inspect the connection's DB type before invoking and branch to the MySQL-specific path.
  3. If using the generic DBManager interface, treat BusinessException with this code as 'unsupported' and degrade gracefully in the UI.
  4. Confirm the caller is not sending a real schema name expecting a schema-scoped drop on MySQL.

Example fix

// before
dbManager.dropSchema(connection, databaseName, schemaName);

// after
if (isMysql(connection)) {
    dbManager.dropDatabase(connection, databaseName);
} else {
    dbManager.dropSchema(connection, databaseName, schemaName);
}
Defensive patterns

Strategy: validation

Validate before calling

if (supportsSchemas(connection)) {
    dbManager.dropSchema(connection, databaseName, schemaName);
} else {
    dbManager.dropDatabase(connection, databaseName);
}

Type guard

static boolean mysqlSupportsSchema() {
    return false; // MySQL treats schema == database
}

Try / catch

try {
    dbManager.dropSchema(connection, databaseName, schemaName);
} catch (BusinessException e) {
    if ("database.delete.notSupportSchema".equals(e.getCode())) {
        dbManager.dropDatabase(connection, databaseName);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling dbManager.dropSchema(connection, databaseName, schemaName) on a MySQL-backed connection. Any non-null arguments produce this because the body never inspects them.

Common situations: Generic multi-dialect UI code invokes dropSchema uniformly across plugins; on a MySQL datasource this hits the no-op branch. Also occurs when migrating schema objects from a schema-aware dialect (PostgreSQL/Oracle) and replaying the same calls against MySQL.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/73a2e28af36cfb55. Report an issue: GitHub.