Principle:Apache Dolphinscheduler Connection Testing
| Knowledge Sources | |
|---|---|
| Domains | Data_Integration, Connection_Management |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
A lightweight connection verification mechanism that tests database connectivity using ad-hoc single-use connections before persisting datasource configurations.
Description
The Connection Testing principle ensures that datasource configurations are valid before they are saved. It uses the checkDataSourceConnectivity() method which creates a short-lived ad-hoc connection to the target database, verifying that the JDBC URL, credentials, and driver are correct. The test uses BaseAdHocDataSourceClient which creates a single JDBC connection and immediately closes it, avoiding the overhead of connection pooling.
This "test before save" pattern prevents invalid configurations from entering the system, which would cause task execution failures at runtime.
Usage
Connection testing should be performed whenever a user creates or updates a datasource configuration. It is exposed through the DolphinScheduler API as a "test connection" endpoint.
Theoretical Basis
The testing follows a Fail-Fast Pattern:
testConnection(connectionParam):
try:
connection = adHocClient.getConnection() // single-use JDBC connection
connection.close()
return true // connectivity verified
catch SQLException:
return false // connection failed