OtterMind/Chat2DB · error · BusinessException
dataSourceConnect.getMessage()
Error message
dataSourceConnect.getMessage()
What it means
Thrown after JdbcUtils.testConnect(...) returns success=false; the BusinessException code is set to dataSourceConnect.getMessage() (the driver/connection error text) with description and errorDetail as args. This is the dynamic failure path for a connection test.
Source
Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDataSourceServiceImpl.java:68
}
Map<String, Object> map = KeyValue.toMap(param.getExtendInfo());
if(StringUtils.isNotBlank(param.getProject())){
map.put("ProjectId",param.getProject());
}
if(StringUtils.isNotBlank(param.getEmail())){
map.put("OAuthServiceAcctEmail",param.getEmail());
}
if(StringUtils.isNotBlank(param.getKeyfile())){
map.put("OAuthType","0");
map.put("OAuthPvtKeyPath",param.getKeyfile());
}
DataSourceConnect dataSourceConnect = JdbcUtils.testConnect(testParam.getUrl(), testParam.getHost(),
testParam.getPort(),
testParam.getUsername(), testParam.getPassword(), testParam.getDbType(),
driverConfig, param.getSsh(),map);
if (BooleanUtils.isNotTrue(dataSourceConnect.getSuccess())) {
throw new BusinessException(dataSourceConnect.getMessage(),
new Object[]{dataSourceConnect.getDescription(), dataSourceConnect.getErrorDetail()});
}
}
@Override
public List<Database> connect(Long id) {
DbDatabaseQueryAllRequest queryAllParam = new DbDatabaseQueryAllRequest();
queryAllParam.setDataSourceId(id);
return Chat2DBContext.getDbMetaData().databases(Chat2DBContext.getConnection());
}
@Override
public void close(Long id) {
DbDataSourceCloseRequest closeParam = new DbDataSourceCloseRequest();
closeParam.setDataSourceId(id);
}
@OverrideView on GitHub (pinned to 5ee1e990e7)
Solutions
- Read dataSourceConnect.getDescription()/getErrorDetail() to get the driver-specific cause and correct host/port/credentials accordingly.
- Confirm the driver jar for the dbType is present and loaded (see connection.driver.load.error).
- For OAuth-keyed DBs, provide a valid service-account email and keyfile.
- Verify network/SSH reachability to the DB host before re-testing.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: ensure required fields are present before testing
if (StringUtils.isAnyBlank(testParam.getHost(), testParam.getUrl()) && dbTypeNeedsHost(testParam.getDbType())) {
return Result.fail("connection.error");
} Try / catch
try {
dataSourceService.testConnection(param);
} catch (BusinessException e) {
// e.getCode() holds the driver error text; e.getArgs() has [description, errorDetail]
// surface these to the user to correct host/port/credentials/driver
} Prevention
- Provide host, port, credentials, and (for OAuth DBs) email/keyfile before testing.
- Confirm the driver jar for the dbType is loaded.
- Check network/SSH reachability before re-testing.
When it happens
Trigger: DbDataSourceServiceImpl.testConnection() runs a JDBC test connect and the driver reports failure — wrong host/port, bad credentials, unreachable host, missing/incompatible driver, unsupported auth (e.g. OAuth params), or SSH tunnel issues.
Common situations: Incorrect host/port or credentials in the datasource form, driver jar not loaded for the dbType, firewall/network blocking the DB port, GCP BigQuery OAuth misconfiguration (missing email/keyfile), or a dialect/version mismatch.
Related errors
- datasource_connection_failed
- connection.ssh.error
- sql_query_failed
- connection error
- largeCellValue.readFailed
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/e51f133c412ba9ab.
Report an issue: GitHub.