OtterMind/Chat2DB · error · BusinessException
database.delete.connectionDatabaseMismatch
database.delete.connectionDatabaseMismatch
Error message
database.delete.connectionDatabaseMismatch
What it means
Thrown by executeSchemaDelete() when profile.getDatabaseName() does NOT equal the requested databaseName. Schema deletion must target the database the current connection is actually bound to, so a mismatch is rejected.
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:133
Chat2DBContext.getDbManager(dbType).dropDatabase(connection, databaseName);
} catch (BusinessException e) {
throw e;
} catch (Exception e) {
throw new BusinessException("database.delete.executeFailed", new Object[]{e.getMessage()}, e);
}
}
@Override
public void executeSchemaDelete(DbDatabaseObjectDeleteExecuteRequest param) {
ConnectionProfile profile = requireCurrentProfile();
String dbType = requireSupportedDbType(profile);
String databaseName = requireName(param.getDatabaseName(), "databaseName");
String schemaName = requireName(param.getSchemaName(), "schemaName");
assertSchemaDeletionSupported(dbType);
rejectSystemSchema(dbType, schemaName);
assertConfirmName(param.getConfirmName(), schemaConfirmName(schemaName));
if (!StringUtils.equals(profile.getDatabaseName(), databaseName)) {
throw new BusinessException("database.delete.connectionDatabaseMismatch");
}
Connection connection = requireConnection();
try {
assertSchemaExists(connection, databaseName, schemaName);
Chat2DBContext.getDbManager(dbType).dropSchema(connection, databaseName, schemaName);
} catch (BusinessException e) {
throw e;
} catch (Exception e) {
throw new BusinessException("database.delete.executeFailed", new Object[]{e.getMessage()}, e);
}
}
private ConnectionProfile requireCurrentProfile() {
ConnectionProfile profile = connectionContextService.currentProfile();
if (profile == null) {
throw new BusinessException("database.delete.invalidDataSource");
}
return profile;View on GitHub (pinned to 5ee1e990e7)
Solutions
- Switch/rebind the connection to the target database (rebindCurrentDatabase) before issuing executeSchemaDelete.
- Confirm the request's databaseName exactly matches profile.getDatabaseName() (mind case-sensitivity).
- Re-prepare from the correct database context.
Defensive patterns
Strategy: validation
Validate before calling
// Before executeSchemaDelete
ConnectionProfile profile = connectionContextService.currentProfile();
if (profile == null || !StringUtils.equals(profile.getDatabaseName(), param.getDatabaseName())) {
// rebind/switch to the target database first
return Result.fail("database.delete.connectionDatabaseMismatch");
} Prevention
- Switch the connection to the target database before schema deletion.
- Mind case-sensitivity when comparing database names on some dialects.
- Re-prepare from the correct database context.
When it happens
Trigger: A drop-schema execute request names a database different from the connection's current database. Unlike database delete, schema delete does not rebind, so the connection's database must already match.
Common situations: Frontend sends a schema-delete for a database other than the connected one; profile is stale after a switch; mismatched databaseName casing for case-sensitive dialects.
Related errors
- database.delete.connectionTargetsDeletedDatabase
- database.delete.prepareFailed
- database.delete.executeFailed
- database.delete.invalidDataSource
- database.delete.notSupportDbType
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/ea05bc7e25c547f3.
Report an issue: GitHub.