{"record":{"id":"e51f133c412ba9ab","repo":"OtterMind/Chat2DB","slug":"datasourceconnect-getmessage","errorCode":null,"errorMessage":"dataSourceConnect.getMessage()","messagePattern":"dataSourceConnect\\.getMessage\\(\\)","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/DbDataSourceServiceImpl.java","lineNumber":68,"sourceCode":"        }\n        Map<String, Object> map = KeyValue.toMap(param.getExtendInfo());\n        if(StringUtils.isNotBlank(param.getProject())){\n            map.put(\"ProjectId\",param.getProject());\n        }\n        if(StringUtils.isNotBlank(param.getEmail())){\n            map.put(\"OAuthServiceAcctEmail\",param.getEmail());\n        }\n        if(StringUtils.isNotBlank(param.getKeyfile())){\n            map.put(\"OAuthType\",\"0\");\n            map.put(\"OAuthPvtKeyPath\",param.getKeyfile());\n        }\n\n        DataSourceConnect dataSourceConnect = JdbcUtils.testConnect(testParam.getUrl(), testParam.getHost(),\n                testParam.getPort(),\n                testParam.getUsername(), testParam.getPassword(), testParam.getDbType(),\n                driverConfig, param.getSsh(),map);\n        if (BooleanUtils.isNotTrue(dataSourceConnect.getSuccess())) {\n            throw new BusinessException(dataSourceConnect.getMessage(),\n                    new Object[]{dataSourceConnect.getDescription(), dataSourceConnect.getErrorDetail()});\n        }\n    }\n\n    @Override\n    public List<Database> connect(Long id) {\n        DbDatabaseQueryAllRequest queryAllParam = new DbDatabaseQueryAllRequest();\n        queryAllParam.setDataSourceId(id);\n        return Chat2DBContext.getDbMetaData().databases(Chat2DBContext.getConnection());\n    }\n\n    @Override\n    public void close(Long id) {\n        DbDataSourceCloseRequest closeParam = new DbDataSourceCloseRequest();\n        closeParam.setDataSourceId(id);\n    }\n\n    @Override","sourceCodeStart":50,"sourceCodeEnd":86,"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/DbDataSourceServiceImpl.java#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: ensure required fields are present before testing\nif (StringUtils.isAnyBlank(testParam.getHost(), testParam.getUrl()) && dbTypeNeedsHost(testParam.getDbType())) {\n    return Result.fail(\"connection.error\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    dataSourceService.testConnection(param);\n} catch (BusinessException e) {\n    // e.getCode() holds the driver error text; e.getArgs() has [description, errorDetail]\n    // surface these to the user to correct host/port/credentials/driver\n}","preventionTips":["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."],"tags":["connection","jdbc","test-connect","driver","credentials"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}