{"record":{"id":"6aacb13993f8dda4","repo":"OtterMind/Chat2DB","slug":"drop-table-error","errorCode":"drop table error","errorMessage":"drop table error","messagePattern":"drop table error","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/DbTableServiceImpl.java","lineNumber":297,"sourceCode":"        if (table == null) {\n            return null;\n        }\n        table.setIndexList(Lists.newArrayList());\n        fillAITableInfo(param, table);\n        return Chat2DBContext.getSqlBuilder().ddl().table().buildAITableSchema(table);\n    }\n\n    @Override\n    public void dropTable(DbTableQueryRequest param) {\n        try {\n            Connection connection = Chat2DBContext.getConnection();\n            IDbManager dbManager = Chat2DBContext.getDbManager();\n            String sql = dbManager.dropTable(connection, param.getDatabaseName(), param.getSchemaName(),\n                    param.getTableName());\n            DefaultSQLExecutor.getInstance().execute(connection, sql, resultSet -> null);\n        } catch (Exception e) {\n            log.error(\"drop table error\", e);\n            throw new BusinessException(\"drop table error\", new Object[]{e.getMessage()}, e);\n        }\n    }\n\n    @Override\n    public void truncateTable(DbTableQueryRequest param) {\n        try {\n            IDbMetaData metaData = Chat2DBContext.getDbMetaData();\n            Connection connection = Chat2DBContext.getConnection();\n            String name = metaData.getMetaDataName(param.getTableName());\n            String sql = Chat2DBContext.getDbManager()\n                    .truncateTable(connection, param.getDatabaseName(), param.getSchemaName(), name);\n            DefaultSQLExecutor.getInstance().execute(connection, sql, resultSet -> null);\n        } catch (Exception e) {\n            log.error(\"truncate table error\", e);\n            throw new BusinessException(\"truncate table error\", new Object[]{e.getMessage()}, e);\n        }\n    }\n","sourceCodeStart":279,"sourceCodeEnd":315,"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/DbTableServiceImpl.java#L279-L315","documentation":"Thrown by DbTableServiceImpl.dropTable to wrap any Exception from the drop path (Chat2DBContext.getDbManager().dropTable SQL generation + DefaultSQLExecutor.execute). It carries the original exception as cause and e.getMessage() as an arg. NOTE: the code is the literal 'drop table error' (with spaces), NOT a defined i18n key, so the user-facing message becomes the raw 'drop table error : no message.' and the underlying DB message (the arg) is not interpolated into any template.","triggerScenarios":"The DB rejects DROP TABLE: insufficient privileges, foreign-key constraints referencing the table, table does not exist, dependent views/objects, reserved/quoted identifier issues, or the connection was lost mid-operation.","commonSituations":"Dropping a table referenced by FKs/views; non-owner/low-privilege user; case-sensitivity or schema mismatch; a stale table list where the table was already dropped elsewhere.","solutions":["Inspect the logged cause (log.error(\"drop table error\", e)) for the exact DB error and address it (drop dependent objects first, grant DROP privilege).","Verify database/schema/table name case and that the table exists before calling dropTable.","Add the i18n key 'drop table error=Failed to drop table: {0}' (or rename the code to a dotted key) so the DB message surfaces to the user."],"exampleFix":"// before\nthrow new BusinessException(\"drop table error\", new Object[]{e.getMessage()}, e);\n// renders: \"drop table error : no message.\"\n\n// after (add i18n key)\n// ddl.dropFailed=Failed to drop table: {0}\nthrow new BusinessException(\"ddl.dropFailed\", new Object[]{e.getMessage()}, e);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    tableService.dropTable(param);\n} catch (BusinessException e) { // code \"drop table error\"\n    // e.getCause() holds the real DB SQLException; inspect it for FK/privilege errors\n}","preventionTips":["Pre-check privileges and dependent objects before dropping.","Add a dotted i18n key so the DB error message surfaces to users."],"tags":["ddl","table-operations","i18n-missing-key","database-error"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}