{"record":{"id":"0358083fb3b2166d","repo":"apache/dolphinscheduler","slug":"datasource-connect-failed","errorCode":"DATASOURCE_CONNECT_FAILED","errorMessage":"Status.DATASOURCE_CONNECT_FAILED","messagePattern":"Status\\.DATASOURCE_CONNECT_FAILED","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java","lineNumber":370,"sourceCode":"        DataSource dataSource = dataSourceDao.queryById(datasourceId);\n\n        if (dataSource == null) {\n            throw new ServiceException(Status.QUERY_DATASOURCE_ERROR);\n        }\n\n        if (!canOperatorPermissions(loginUser, new Object[]{datasourceId}, AuthorizationType.DATASOURCE,\n                ApiFuncIdentificationConstant.DATASOURCE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        List<String> tableList;\n        BaseConnectionParam connectionParam =\n                (BaseConnectionParam) DataSourceUtils.buildConnectionParams(\n                        dataSource.getType(),\n                        dataSource.getConnectionParams());\n\n        if (null == connectionParam) {\n            throw new ServiceException(Status.DATASOURCE_CONNECT_FAILED);\n        }\n\n        Connection connection =\n                DataSourceUtils.getConnection(dataSource.getType(), connectionParam);\n        ResultSet tables = null;\n\n        try {\n\n            if (null == connection) {\n                throw new ServiceException(Status.DATASOURCE_CONNECT_FAILED);\n            }\n\n            DatabaseMetaData metaData = connection.getMetaData();\n            String schema = null;\n            try {\n                schema = metaData.getConnection().getSchema();\n            } catch (SQLException e) {\n                log.error(\"Can not get the schema, datasourceId:{}.\", datasourceId, e);","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java#L352-L388","documentation":"getTables throws DATASOURCE_CONNECT_FAILED when DataSourceUtils.buildConnectionParams returns null after converting the stored datasource into BaseConnectionParam. This indicates the stored connection parameters could not be turned into usable JDBC connection params.","triggerScenarios":"Datasource row exists but its connectionParams JSON is missing/invalid for the given type, so buildConnectionParams(type, connectionParams) yields null; typically corrupt or partially-updated datasource records.","commonSituations":"Datasource created by an older DolphinScheduler version whose params format changed after upgrade; datasource type changed without updating stored params; manually edited t_ds_datasource rows.","solutions":["Re-open the datasource in the UI and re-save its connection parameters to regenerate valid params","Verify the datasource type matches the stored connectionParams JSON shape","Recreate the datasource if the stored record is corrupt","Check DolphinScheduler upgrade notes for datasource param format changes"],"exampleFix":"// caller side: validate datasource before browsing tables\nif (dataSource.getConnectionParams() == null || dataSource.getConnectionParams().isEmpty()) {\n    throw new IllegalStateException(\"Datasource \" + dataSource.getName() + \" has no connection params; re-save it\");\n}","handlingStrategy":"validation","validationCode":"DataSource ds = dataSourceDao.queryById(datasourceId);\nif (ds == null || ds.getConnectionParams() == null || ds.getConnectionParams().isEmpty()) {\n    throw new IllegalStateException(\"Datasource has missing/corrupt connection params; re-save it\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-save datasources after DolphinScheduler upgrades to refresh param formats","Never hand-edit t_ds_datasource connectionParams directly","Use the UI 'test connection' after creating or editing a datasource"],"tags":["datasource","jdbc","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}