{"record":{"id":"cbaa99a98b0573a9","repo":"apache/beam","slug":"jdbc-type-must-be-one-of-jdbc-driver-map-keyset-but-was","errorCode":null,"errorMessage":"JDBC type must be one of ${JDBC_DRIVER_MAP.keySet()} but was ${jdbcType}","messagePattern":"JDBC type must be one of (.+?) but was (.+?)","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":407,"sourceCode":"        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.\");\n      }\n    }\n\n    public static Builder builder() {\n      return new AutoValue_JdbcWriteSchemaTransformProvider_JdbcWriteSchemaTransformConfiguration","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcWriteSchemaTransformProvider.java#L389-L425","documentation":"When a jdbcType IS provided, it must match a key in the provider's JDBC_DRIVER_MAP (case-insensitive). An unknown value like \"postgresql\" or \"pg\" when the map expects \"postgres\" throws this IllegalArgumentException listing the valid keys.","triggerScenarios":"Calling validate() with jdbcType set to a string not contained (after lowercasing) in JDBC_DRIVER_MAP keySet, e.g. \"postgresql\", \"sqlserver\", \"db2\".","commonSituations":"Typos or synonyms: \"postgresql\" instead of \"postgres\"; using a driver family Beam's map does not include; passing a URL fragment as jdbcType by mistake.","solutions":["Use one of the supported keys exactly as printed in the error message (e.g. \"postgres\", \"mysql\", \"mssql\", \"oracle\")","Lowercase the value before passing it if it comes from user input (comparison is case-insensitive, but spelling must match)","For unsupported databases, switch to driverClassName + driverJars instead of jdbcType"],"exampleFix":"// before\nbuilder().setJdbcType(\"postgresql\").build();\n// after\nbuilder().setJdbcType(\"postgres\").build();","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"postgres\", \"mysql\", \"mssql\", \"oracle\"); // mirrors JDBC_DRIVER_MAP keys\nif (jdbcType != null && !allowed.contains(jdbcType.toLowerCase())) {\n  throw new IllegalArgumentException(\"Unsupported jdbcType: \" + jdbcType);\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"JDBC type must be one of\")) {\n    LOG.error(\"Use one of the listed jdbcType keys: {}\", e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Copy jdbcType values from the error message's allowed keySet verbatim","Use \"postgres\" not \"postgresql\"; \"mssql\" not \"sqlserver\"","For unlisted databases use driverClassName + driverJars instead"],"tags":["jdbc","beam","enum","config"],"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-14T16:17:12.679Z"}