{"record":{"id":"1b7165440e587240","repo":"apache/beam","slug":"one-of-jdbc-driver-class-name-or-jdbc-type-must-be-specified","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/JdbcReadSchemaTransformProvider.java","lineNumber":417,"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(\"JDBC type must be one of \" + JDBC_DRIVER_MAP.keySet());\n      }\n\n      boolean readQueryPresent = (getReadQuery() != null && !\"\".equals(getReadQuery()));\n      boolean locationPresent = (getLocation() != null && !\"\".equals(getLocation()));\n      boolean partitionColumnPresent =\n          (getPartitionColumn() != null && !\"\".equals(getPartitionColumn()));\n\n      // If you specify a readQuery, it is to be used instead of a table.\n      if (readQueryPresent && locationPresent) {\n        throw new IllegalArgumentException(\"Query and Table are mutually exclusive configurations\");\n      }\n      if (!readQueryPresent && !locationPresent) {\n        throw new IllegalArgumentException(\"Either Query or Table must be specified.\");","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java#L399-L435","documentation":"If driverClassName is absent, the provider falls back to jdbcType which must be a key of JDBC_DRIVER_MAP (a fixed set of known database types). When neither driverClassName nor a recognized jdbcType is present, validate() throws this IllegalArgumentException.","triggerScenarios":"Calling validate()/from() with a config that has empty driverClassName and a jdbcType that is null/empty, or when the second check is reached with an unrecognized jdbcType (the sibling error 'JDBC type must be one of ...' covers non-null unknown values).","commonSituations":"Passing jdbcType values like 'postgres' or 'MySQL' with wrong casing/abbreviation not in the map while driverClassName is unset; omitting driver fields entirely.","solutions":["Use an exact key from JDBC_DRIVER_MAP in lowercase (e.g. 'postgresql', 'mysql', 'mssql', 'oracle').","Alternatively provide driverClassName + driverJars to bypass the jdbcType map.","Log/print JDBC_DRIVER_MAP.keySet() at config build time to pick a valid value."],"exampleFix":"// before\nbuilder().setJdbcType(\"postgres\")\n// after\nbuilder().setJdbcType(\"postgresql\") // or setDriverClassName(\"org.postgresql.Driver\").setDriverJars(...)","handlingStrategy":"validation","validationCode":"String t = config.getJdbcType();\nif ((config.getDriverClassName() == null || config.getDriverClassName().isEmpty())\n    && (t == null || t.isEmpty())) {\n  throw new IllegalArgumentException(\"jdbcType or driverClassName required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"One of JDBC Driver class name or JDBC type\")) {\n    throw new IllegalStateException(\"Unknown jdbcType; use a JDBC_DRIVER_MAP key\", e);\n  }\n  throw e;\n}","preventionTips":["Normalize jdbcType with toLowerCase() before assignment.","Prefer explicit driverClassName+driverJars for less common engines.","Validate the value against the documented list of supported types in CI."],"tags":["jdbc","java","validation","driver"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}