OtterMind/Chat2DB · error · BusinessException

database.delete.notSupportDatabase

database.delete.notSupportDatabase

Error message

database.delete.notSupportDatabase

What it means

Thrown by assertDatabaseDeletionSupported when the resolved DBConfig is null or its isSupportDatabase() flag is false for the current connection's dbType. This guards prepareDatabaseDelete and executeDatabaseDelete so that database-level DROP operations are only attempted on DB types that actually expose a database concept. It is a capability check on the dialect plugin configuration, not a runtime permission check.

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java:180

    private void reconnectForDatabaseDelete(String dbType) {
        if (!DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {
            return;
        }
        connectionContextService.rebindCurrentDatabase(maintenanceDatabase());
    }

    private String requireName(String name, String fieldName) {
        String trimmed = StringUtils.trimToNull(name);
        if (trimmed == null) {
            throw new BusinessException("database.delete." + fieldName + "Required");
        }
        return trimmed;
    }

    private void assertDatabaseDeletionSupported(String dbType) {
        DBConfig dbConfig = Chat2DBContext.getDBConfig(dbType);
        if (dbConfig == null || !dbConfig.isSupportDatabase()) {
            throw new BusinessException("database.delete.notSupportDatabase");
        }
    }

    private void rejectSystemDatabase(String dbType, String databaseName) {
        if (DatabaseTypeEnum.MYSQL.name().equalsIgnoreCase(dbType)
                && MYSQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {
            throw new BusinessException("database.delete.systemDatabaseForbidden");
        }
        if (DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)
                && POSTGRESQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {
            throw new BusinessException("database.delete.systemDatabaseForbidden");
        }
    }

    private Connection requireConnection() {
        Connection connection = Chat2DBContext.getConnection();
        if (connection == null) {
            throw new BusinessException("database.delete.connectionFailed");

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Switch the active datasource to a MySQL or PostgreSQL connection before invoking database delete.
  2. Verify the dbType stored on the ConnectionProfile resolves to a DBConfig whose isSupportDatabase() is true (check the dialect's DBConfig registration).
  3. If the dialect genuinely supports databases, correct the plugin's DBConfig so isSupportDatabase() returns true.

Example fix

// before
ConnectionProfile profile = connectionContextService.currentProfile();
dlTemplateService.prepareDatabaseDelete(req); // dbType=REDIS -> notSupportDatabase

// after
// ensure profile.getDbType() is MYSQL or POSTGRESQL before calling
if (Set.of("MYSQL","POSTGRESQL").contains(StringUtils.upperCase(profile.getDbType()))) {
    dlTemplateService.prepareDatabaseDelete(req);
}
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check database-deletion capability before calling prepare/execute
DBConfig cfg = Chat2DBContext.getDBConfig(dbType);
if (cfg == null || !cfg.isSupportDatabase()) {
    // do not call prepareDatabaseDelete / executeDatabaseDelete
    return;
}

Prevention

When it happens

Trigger: Calling prepareDatabaseDelete() or executeDatabaseDelete() on a connection whose dbType (e.g. REDIS, MONGODB, or a flat-namespace dialect) has DBConfig.isSupportDatabase()==false, or whose dbType has no registered DBConfig (Chat2DBContext.getDBConfig returns null). Only MYSQL and POSTGRESQL connections pass this gate in the current SUPPORTED_TYPES set.

Common situations: Selecting a Redis/MongoDB/Oracle connection in the UI and invoking the delete-database action; pointing the datasource at a dbType string that does not match any registered plugin DBConfig key; a plugin misconfiguration where isSupportDatabase was left at its default false.

Related errors


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