{"record":{"id":"de681f9b4c56d0ed","repo":"OtterMind/Chat2DB","slug":"database-delete-executefailed","errorCode":"database.delete.executeFailed","errorMessage":"database.delete.executeFailed","messagePattern":"database\\.delete\\.executeFailed","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java","lineNumber":119,"sourceCode":"        ConnectionProfile profile = requireCurrentProfile();\n        String dbType = requireSupportedDbType(profile);\n        reconnectForDatabaseDelete(dbType);\n        profile = requireCurrentProfile();\n        String databaseName = requireName(param.getDatabaseName(), \"databaseName\");\n        assertDatabaseDeletionSupported(dbType);\n        rejectSystemDatabase(dbType, databaseName);\n        assertConfirmName(param.getConfirmName(), databaseConfirmName(databaseName));\n        if (StringUtils.equals(profile.getDatabaseName(), databaseName)) {\n            throw new BusinessException(\"database.delete.connectionTargetsDeletedDatabase\");\n        }\n        Connection connection = requireConnection();\n        try {\n            assertDatabaseExists(connection, dbType, databaseName);\n            Chat2DBContext.getDbManager(dbType).dropDatabase(connection, databaseName);\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new BusinessException(\"database.delete.executeFailed\", new Object[]{e.getMessage()}, e);\n        }\n    }\n\n    @Override\n    public void executeSchemaDelete(DbDatabaseObjectDeleteExecuteRequest param) {\n        ConnectionProfile profile = requireCurrentProfile();\n        String dbType = requireSupportedDbType(profile);\n        String databaseName = requireName(param.getDatabaseName(), \"databaseName\");\n        String schemaName = requireName(param.getSchemaName(), \"schemaName\");\n        assertSchemaDeletionSupported(dbType);\n        rejectSystemSchema(dbType, schemaName);\n        assertConfirmName(param.getConfirmName(), schemaConfirmName(schemaName));\n        if (!StringUtils.equals(profile.getDatabaseName(), databaseName)) {\n            throw new BusinessException(\"database.delete.connectionDatabaseMismatch\");\n        }\n        Connection connection = requireConnection();\n        try {\n            assertSchemaExists(connection, databaseName, schemaName);","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java#L101-L137","documentation":"Wraps any non-BusinessException raised during executeDatabaseDelete() while checking existence and calling getDbManager(dbType).dropDatabase(...). 'Failed to execute deletion: {0}' with the cause chained.","triggerScenarios":"dropDatabase throws SQLException (permissions, active connections blocking drop, object dependencies), or assertDatabaseExists fails unexpectedly after the connection check.","commonSituations":"Insufficient privileges to DROP DATABASE, other open connections to the target DB, dependencies/locks, or the DB was removed between prepare and execute.","solutions":["Read the wrapped cause ({0}) to identify the DROP failure reason.","Terminate other connections to the target database and ensure the role has DROP privilege.","Re-run prepare+execute if the DB was removed concurrently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    deleteService.executeDatabaseDelete(param);\n} catch (BusinessException e) {\n    if (\"database.delete.executeFailed\".equals(e.getCode())) {\n        // e.getCause() is the DROP failure; e.getArgs()[0] its message\n        // advise: close other connections / grant DROP privilege\n    } else {\n        throw e;\n    }\n}","preventionTips":["Close other connections to the target database before dropping.","Ensure the role has DROP DATABASE privilege.","Re-run prepare+execute if the DB was removed concurrently."],"tags":["database","delete","ddl","execute","jdbc"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}