{"record":{"id":"6fe844a7bf1b7559","repo":"apache/beam","slug":"if-jdbc-type-is-not-specified-then-driver-class-name-and-6fe844","errorCode":null,"errorMessage":"If JDBC type is not specified, then Driver Class Name and Driver Jars must be specified.","messagePattern":"If JDBC type is not specified, then Driver Class Name and Driver Jars 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":398,"sourceCode":"    @Nullable\n    public abstract String getWriteStatement();\n\n    public void validate() {\n      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(","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcWriteSchemaTransformProvider.java#L380-L416","documentation":"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.","triggerScenarios":"Calling validate() with jdbcType, driverClassName, and driverJars all absent — none of the three driver-identifying options was configured.","commonSituations":"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.","solutions":["Set jdbcType to a supported value such as \"postgres\", \"mysql\", or \"mssql\"","Or set driverClassName (e.g. \"org.postgresql.Driver\") together with driverJars pointing to the driver artifact","If using a non-bundled driver, stage it via driverJars so the runner can load it"],"exampleFix":"// before\nbuilder().setJdbcUrl(url).setLocation(\"mytable\").build();\n// after\nbuilder().setJdbcUrl(url).setJdbcType(\"postgres\").setLocation(\"mytable\").build();","handlingStrategy":"validation","validationCode":"if (Strings.isNullOrEmpty(cfg.getJdbcType())\n    && Strings.isNullOrEmpty(cfg.getDriverClassName())\n    && Strings.isNullOrEmpty(cfg.getDriverJars())) {\n  throw new IllegalArgumentException(\"Provide jdbcType, or driverClassName + driverJars\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Driver Class Name and Driver Jars must be specified\")) {\n    LOG.error(\"Missing driver identification: set jdbcType or driverClassName+driverJars\");\n  }\n  throw e;\n}","preventionTips":["Prefer jdbcType (postgres/mysql/mssql/oracle) — it fills in the driver automatically","For custom drivers, always set driverClassName together with driverJars","Review the provider README table of supported jdbcType values"],"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"}