OtterMind/Chat2DB · error · BusinessException

connection error

connection error

Error message

connection error

What it means

Thrown by requireConnection() when Chat2DBContext.getConnection() returns null, meaning no JDBC connection is bound to the current request's thread-local context. The account admin service needs a live connection to enumerate/manage DB accounts. Note the code key is the literal string 'connection error' (with a space); the i18n catalog only defines 'connection.error' (dotted), so the message likely renders raw rather than as 'Connection failed, please check the connection information'.

Source

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

    }

    @Override
    public AccountExecuteResponse execute(AccountOperationRequest command) {
        return requireAccountManager().execute(requireConnection(), command);
    }

    private IAccountManager requireAccountManager() {
        IAccountManager accountManager = Chat2DBContext.getAccountManager();
        if (accountManager == null) {
            throw new BusinessException("account.manage.unsupported");
        }
        return accountManager;
    }

    private Connection requireConnection() {
        Connection connection = Chat2DBContext.getConnection();
        if (connection == null) {
            throw new BusinessException("connection error");
        }
        return connection;
    }
}

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure DbConnectionContextServiceImpl.connect(...) ran successfully on the current thread before invoking account-admin methods; check that connectInfo was actually pushed via Chat2DBContext.putContext.
  2. If you restructured request scoping, verify the interceptor/filter that calls connect() still precedes account endpoints.
  3. Fix the message key mismatch: use 'connection.error' (dotted) so the i18n message resolves, since BusinessException.code is looked up verbatim.

Example fix

// before
throw new BusinessException("connection error");
// after
throw new BusinessException("connection.error");
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking any account-admin method:
if (Chat2DBContext.getConnection() == null) {
    // open a connection context first, or return a 'connect required' response
    dbConnectionContextService.connect(connectRequest);
}
if (Chat2DBContext.getConnection() == null) {
    return Result.fail("connection.error");
}

Prevention

When it happens

Trigger: Calling any account-management API on DbAccountAdminServiceImpl (e.g. list/create/drop DB users) before a connection context was opened via DbConnectionContextServiceImpl.connect(), or after it was cleared/closed mid-request. Also when requireAccountManager() passes but the connection itself was never bound.

Common situations: A controller endpoint invoked without the connection-context middleware having run (missing @Connect interceptor), a prior connect() that failed silently, or clear()/close() called earlier in the same thread. Race between MCP context setup and an account call.

Related errors


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