OtterMind/Chat2DB · error · BusinessException
connection error
Error message
connection error
What it means
Thrown by DbRoutineOperationServiceImpl.previewInvocation when Chat2DBContext.getConnection() returns null, i.e. no live JDBC connection is bound to the current context. NOTE: the code is the literal string 'connection error' (with a space), NOT the i18n key 'connection.error', so it is NOT localized and renders as the raw 'connection error : no message.' This is a defect in the thrown code; the intended key 'connection.error' ('Connection failed, please check the connection information') is never reached on this path.
Source
Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbRoutineOperationServiceImpl.java:29
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.sql.Connection;
@Service
public class DbRoutineOperationServiceImpl implements IDbRoutineOperationService {
@Override
public SqlPreview previewInvocation(RoutineOperation operation) {
IRoutineManager routineManager = Chat2DBContext.getRoutineManager();
if (routineManager == null) {
throw new BusinessException("routine.operation.onlyMysqlSupported");
}
Connection connection = Chat2DBContext.getConnection();
if (connection == null) {
throw new BusinessException("connection error");
}
return routineManager.previewInvocation(connection, completeOperation(operation));
}
@Override
public SqlPreview previewMigration(RoutineOperation operation) {
IRoutineManager routineManager = Chat2DBContext.getRoutineManager();
if (routineManager == null) {
throw new BusinessException("routine.operation.onlyMysqlSupported");
}
Connection connection = Chat2DBContext.getConnection();
if (connection == null) {
throw new BusinessException("connection error");
}
return routineManager.previewMigration(connection, completeOperation(operation));
}
@Override
public ExecuteResponse executeMigration(RoutineOperation operation) {
IRoutineManager routineManager = Chat2DBContext.getRoutineManager();View on GitHub (pinned to 5ee1e990e7)
Solutions
- Ensure a datasource connection is opened and bound in Chat2DBContext before calling routine operations.
- Fix the thrown code to 'connection.error' so the localized message surfaces instead of 'connection error : no message.'.
- Guard routine calls with a connection-availability check upstream.
Example fix
// before
throw new BusinessException("connection error");
// renders: "connection error : no message."
// after
throw new BusinessException("connection.error");
// renders: "Connection failed, please check the connection information" Defensive patterns
Strategy: validation
Validate before calling
if (Chat2DBContext.getConnection() == null) {
// establish/open the datasource connection before routine operations
} Type guard
boolean connectionReady() {
return Chat2DBContext.getConnection() != null;
} Prevention
- Open the datasource connection before invoking routine APIs.
- Fix the thrown code to 'connection.error' for a localized message.
When it happens
Trigger: Calling routine preview without an established datasource connection in the context (connection not opened, dropped, or context not initialized for the request).
Common situations: Request scoped outside the connection-establishment flow; a connection that failed to open silently; invoking routine APIs before selecting/connecting a datasource.
Related errors
- connection error
- connection error
- jdbc.driver.downloadFailed
- No database connection context found. Call list_all_datasour
- No database connection context found. Provide dataSourceId/d
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/cccf84648673d61a.
Report an issue: GitHub.