apache/beam · error · IllegalArgumentException

If JDBC type is not specified, then Driver Class Name and Dr

Error message

If JDBC type is not specified, then Driver Class Name and Driver Jars must be specified.

What it means

The provider needs to know which JDBC driver to load. If neither a named jdbcType (e.g. postgres/mysql from JDBC_DRIVER_MAP), a driverClassName, nor driverJars are provided, it cannot build a connection and throws this IllegalArgumentException.

Source

Thrown at sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcWriteSchemaTransformProvider.java:398

    @Nullable
    public abstract String getWriteStatement();

    public void validate() {
      validate("");
    }

    public void validate(String jdbcType) throws IllegalArgumentException {
      if (Strings.isNullOrEmpty(getJdbcUrl())) {
        throw new IllegalArgumentException("JDBC URL cannot be blank");
      }

      jdbcType = !Strings.isNullOrEmpty(jdbcType) ? jdbcType : getJdbcType();

      boolean driverClassNamePresent = !Strings.isNullOrEmpty(getDriverClassName());
      boolean driverJarsPresent = !Strings.isNullOrEmpty(getDriverJars());
      boolean jdbcTypePresent = !Strings.isNullOrEmpty(jdbcType);
      if (!driverClassNamePresent && !driverJarsPresent && !jdbcTypePresent) {
        throw new IllegalArgumentException(
            "If JDBC type is not specified, then Driver Class Name and Driver Jars must be specified.");
      }
      if (!driverClassNamePresent && !jdbcTypePresent) {
        throw new IllegalArgumentException(
            "One of JDBC Driver class name or JDBC type must be specified.");
      }
      if (jdbcTypePresent
          && !JDBC_DRIVER_MAP.containsKey(Objects.requireNonNull(jdbcType).toLowerCase())) {
        throw new IllegalArgumentException(
            "JDBC type must be one of " + JDBC_DRIVER_MAP.keySet() + " but was " + jdbcType);
      }

      boolean writeStatementPresent =
          (getWriteStatement() != null && !"".equals(getWriteStatement()));
      boolean locationPresent = (getLocation() != null && !"".equals(getLocation()));

      if (writeStatementPresent && locationPresent) {
        throw new IllegalArgumentException(

View on GitHub (pinned to 12126d8942)

Solutions

  1. Set jdbcType to a supported value such as "postgres", "mysql", or "mssql"
  2. Or set driverClassName (e.g. "org.postgresql.Driver") together with driverJars pointing to the driver artifact
  3. If using a non-bundled driver, stage it via driverJars so the runner can load it

Example fix

// before
builder().setJdbcUrl(url).setLocation("mytable").build();
// after
builder().setJdbcUrl(url).setJdbcType("postgres").setLocation("mytable").build();
Defensive patterns

Strategy: validation

Validate before calling

if (Strings.isNullOrEmpty(cfg.getJdbcType())
    && Strings.isNullOrEmpty(cfg.getDriverClassName())
    && Strings.isNullOrEmpty(cfg.getDriverJars())) {
  throw new IllegalArgumentException("Provide jdbcType, or driverClassName + driverJars");
}

Try / catch

try {
  config.validate();
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Driver Class Name and Driver Jars must be specified")) {
    LOG.error("Missing driver identification: set jdbcType or driverClassName+driverJars");
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling validate() with jdbcType, driverClassName, and driverJars all absent — none of the three driver-identifying options was configured.

Common situations: First-time user of the schema-transform write API supplying only table/jdbcUrl; config template with driver section left blank; refactoring that dropped setDriverClassName calls.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/6fe844a7bf1b7559. Report an issue: GitHub.