apache/dolphinscheduler · error · ServiceException

DATASOURCE_CONNECT_FAILED

DATASOURCE_CONNECT_FAILED

Error message

Status.DATASOURCE_CONNECT_FAILED

What it means

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.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java:370

        DataSource dataSource = dataSourceDao.queryById(datasourceId);

        if (dataSource == null) {
            throw new ServiceException(Status.QUERY_DATASOURCE_ERROR);
        }

        if (!canOperatorPermissions(loginUser, new Object[]{datasourceId}, AuthorizationType.DATASOURCE,
                ApiFuncIdentificationConstant.DATASOURCE)) {
            throw new ServiceException(Status.USER_NO_OPERATION_PERM);
        }

        List<String> tableList;
        BaseConnectionParam connectionParam =
                (BaseConnectionParam) DataSourceUtils.buildConnectionParams(
                        dataSource.getType(),
                        dataSource.getConnectionParams());

        if (null == connectionParam) {
            throw new ServiceException(Status.DATASOURCE_CONNECT_FAILED);
        }

        Connection connection =
                DataSourceUtils.getConnection(dataSource.getType(), connectionParam);
        ResultSet tables = null;

        try {

            if (null == connection) {
                throw new ServiceException(Status.DATASOURCE_CONNECT_FAILED);
            }

            DatabaseMetaData metaData = connection.getMetaData();
            String schema = null;
            try {
                schema = metaData.getConnection().getSchema();
            } catch (SQLException e) {
                log.error("Can not get the schema, datasourceId:{}.", datasourceId, e);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Re-open the datasource in the UI and re-save its connection parameters to regenerate valid params
  2. Verify the datasource type matches the stored connectionParams JSON shape
  3. Recreate the datasource if the stored record is corrupt
  4. Check DolphinScheduler upgrade notes for datasource param format changes

Example fix

// caller side: validate datasource before browsing tables
if (dataSource.getConnectionParams() == null || dataSource.getConnectionParams().isEmpty()) {
    throw new IllegalStateException("Datasource " + dataSource.getName() + " has no connection params; re-save it");
}
Defensive patterns

Strategy: validation

Validate before calling

DataSource ds = dataSourceDao.queryById(datasourceId);
if (ds == null || ds.getConnectionParams() == null || ds.getConnectionParams().isEmpty()) {
    throw new IllegalStateException("Datasource has missing/corrupt connection params; re-save it");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/0358083fb3b2166d. Report an issue: GitHub.