{"record":{"id":"03785b0a0ed99149","repo":"apache/beam","slug":"one-of-jdbc-driver-class-name-or-jdbc-type-must-be-specified-03785b","errorCode":null,"errorMessage":"One of JDBC Driver class name or JDBC type must be specified.","messagePattern":"One of JDBC Driver class name or JDBC type must be specified\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcWriteSchemaTransformProvider.java","lineNumber":402,"sourceCode":"      validate(\"\");\n    }\n\n    public void validate(String jdbcType) throws IllegalArgumentException {\n      if (Strings.isNullOrEmpty(getJdbcUrl())) {\n        throw new IllegalArgumentException(\"JDBC URL cannot be blank\");\n      }\n\n      jdbcType = !Strings.isNullOrEmpty(jdbcType) ? jdbcType : getJdbcType();\n\n      boolean driverClassNamePresent = !Strings.isNullOrEmpty(getDriverClassName());\n      boolean driverJarsPresent = !Strings.isNullOrEmpty(getDriverJars());\n      boolean jdbcTypePresent = !Strings.isNullOrEmpty(jdbcType);\n      if (!driverClassNamePresent && !driverJarsPresent && !jdbcTypePresent) {\n        throw new IllegalArgumentException(\n            \"If JDBC type is not specified, then Driver Class Name and Driver Jars must be specified.\");\n      }\n      if (!driverClassNamePresent && !jdbcTypePresent) {\n        throw new IllegalArgumentException(\n            \"One of JDBC Driver class name or JDBC type must be specified.\");\n      }\n      if (jdbcTypePresent\n          && !JDBC_DRIVER_MAP.containsKey(Objects.requireNonNull(jdbcType).toLowerCase())) {\n        throw new IllegalArgumentException(\n            \"JDBC type must be one of \" + JDBC_DRIVER_MAP.keySet() + \" but was \" + jdbcType);\n      }\n\n      boolean writeStatementPresent =\n          (getWriteStatement() != null && !\"\".equals(getWriteStatement()));\n      boolean locationPresent = (getLocation() != null && !\"\".equals(getLocation()));\n\n      if (writeStatementPresent && locationPresent) {\n        throw new IllegalArgumentException(\n            \"Write Statement and Table are mutually exclusive configurations\");\n      }\n      if (!writeStatementPresent && !locationPresent) {\n        throw new IllegalArgumentException(\"Either Write Statement or Table must be set.\");","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcWriteSchemaTransformProvider.java#L384-L420","documentation":"When no explicit driverClassName is given, the provider must resolve the driver from a known jdbcType. If neither is present it throws this IllegalArgumentException, telling the user to supply one of the two.","triggerScenarios":"Calling validate() with driverClassName empty AND jdbcType empty (driverJars alone does not satisfy this check).","commonSituations":"Users assuming driverJars alone is enough; omitting both driver fields when migrating from the older JdbcIO write API to the schema-transform provider.","solutions":["Set jdbcType (e.g. \"postgres\", \"mysql\", \"mssql\", \"oracle\")","Or set driverClassName to the fully qualified driver class","Combine with driverJars for drivers not bundled with Beam"],"exampleFix":"// before\nbuilder().setJdbcUrl(url).setDriverJars(\"gs://bucket/postgres.jar\").build();\n// after\nbuilder().setJdbcUrl(url).setDriverClassName(\"org.postgresql.Driver\").setDriverJars(\"gs://bucket/postgres.jar\").build();","handlingStrategy":"validation","validationCode":"if (Strings.isNullOrEmpty(cfg.getJdbcType()) && Strings.isNullOrEmpty(cfg.getDriverClassName())) {\n  throw new IllegalArgumentException(\"One of jdbcType or driverClassName must be set\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"One of JDBC Driver class name or JDBC type must be specified\")) {\n    LOG.error(\"Set jdbcType or driverClassName; driverJars alone is not enough\");\n  }\n  throw e;\n}","preventionTips":["Remember driverJars alone never satisfies driver resolution","Default to jdbcType for supported databases; driverClassName only for exotic drivers","Call validate() early in pipeline construction to fail fast"],"tags":["jdbc","beam","config","driver"],"backgroundTag":"missing-required-config-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}