apache/seatunnel · warning
Failed to load JDBC driver com.mysql.cj.jdbc.Driver
Error message
Failed to load JDBC driver com.mysql.cj.jdbc.Driver
What it means
WARN logged in the DorisSink constructor when Class.forName("com.mysql.cj.jdbc.Driver") throws, meaning the MySQL Connector/J JDBC driver is not on the classpath. Doris uses the MySQL protocol for JDBC-based operations (e.g. schema change via JDBC/QueryConnection), so a missing driver can break later catalog operations. The sink constructor still completes because the exception is swallowed.
Source
Thrown at seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/sink/DorisSink.java:78
implements SeaTunnelSink<SeaTunnelRow, DorisSinkState, DorisCommitInfo, DorisCommitInfo>,
SupportSaveMode,
SupportMultiTableSink,
SupportSchemaEvolutionSink {
private final DorisSinkConfig dorisSinkConfig;
private final ReadonlyConfig config;
private final CatalogTable catalogTable;
private String jobId;
public DorisSink(ReadonlyConfig config, CatalogTable catalogTable) {
this.config = config;
this.catalogTable = catalogTable;
this.dorisSinkConfig = DorisSinkConfig.of(config);
// Load the JDBC driver in to DriverManager
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (Exception e) {
log.warn("Failed to load JDBC driver com.mysql.cj.jdbc.Driver ", e);
}
}
@Override
public String getPluginName() {
return "Doris";
}
@Override
public void setJobContext(JobContext jobContext) {
this.jobId = jobContext.getJobId();
}
@Override
public DorisSinkWriter createWriter(SinkWriter.Context context) throws IOException {
// Load the JDBC driver in to DriverManager
try {
Class.forName("com.mysql.cj.jdbc.Driver");View on GitHub (pinned to cf67b549a7)
Solutions
- Run sh bin/install-plugin.sh to download the MySQL JDBC driver into the connectors directory
- Manually place mysql-connector-java-8.x.jar (providing com.mysql.cj.jdbc.Driver) in $SEATUNNEL_HOME/connectors and/or lib
- Verify the jar is on the job's classpath for the engine being used (Zeta/Flink/Spark)
- If using MySQL Connector/J 5.x, upgrade to 8.x since com.mysql.cj.jdbc.Driver only exists in 8.x
- Check driver visibility under the plugin classloader and avoid conflicts with shaded jars
Example fix
// before classpath="...;lib/*" // after classpath="...;lib/*;connectors/mysql-connector-java-8.0.27.jar"
Defensive patterns
Strategy: fallback
Validate before calling
try { Class.forName("com.mysql.cj.jdbc.Driver"); }
catch (ClassNotFoundException e) { throw new IllegalStateException("Install mysql-connector-j 8.x"); } Type guard
boolean mysqlDriverPresent() {
try { Class.forName("com.mysql.cj.jdbc.Driver"); return true; }
catch (ClassNotFoundException e) { return false; }
} Try / catch
try { Class.forName("com.mysql.cj.jdbc.Driver"); }
catch (ClassNotFoundException e) { throw new IllegalStateException("Driver missing", e); } Prevention
- Run install-plugin.sh after SeaTunnel install
- Keep mysql-connector-j 8.x jar in connectors/lib on all nodes
- Avoid Connector/J 5.x (wrong class name)
When it happens
Trigger: Instantiating DorisSink (new DorisSink(...)) on a runtime where the mysql-connector-java / mysql-connector-j jar is absent from the plugin classpath — typical when the connector was installed without its dependencies or with an incompatible driver version.
Common situations: Plugin dir missing the MySQL JDBC jar; SeaTunnel Zeta installed via minimal distribution without install-plugin.sh; shaded/older connector versions where the driver class moved; classloader isolation preventing driver visibility.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Failed to load JDBC driver com.mysql.cj.jdbc.Driver
- Failed to load JDBC driver com.mysql.cj.jdbc.Driver
- Failed to load JDBC driver {}
- Failed to load JDBC driver {}
- Could not load service provider for factories.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/6fa77b69b396a0b2.
Report an issue: GitHub.