{"record":{"id":"c436ed4aa696e196","repo":"apache/beam","slug":"jdbc-type-must-be-one-of-jdbc-driver-map-keyset","errorCode":null,"errorMessage":"JDBC type must be one of ${JDBC_DRIVER_MAP.keySet()}","messagePattern":"JDBC type must be one of (.+?)","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":422,"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(\"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.\");\n      }\n      // Reading with partitions only supports table argument.\n      if (partitionColumnPresent && !locationPresent) {\n        throw new IllegalArgumentException(\"Table must be specified to read with partitions.\");\n      }","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java#L404-L440","documentation":"When jdbcType is present, validate() checks it against JDBC_DRIVER_MAP (lowercased). An unrecognized type name means no built-in driver mapping exists, so the provider throws this IllegalArgumentException listing the valid keys.","triggerScenarios":"Setting jdbcType to a string not in JDBC_DRIVER_MAP.keySet() (e.g. 'postgres', 'aurora', 'MariaDB') while driverClassName is not set.","commonSituations":"Case/abbreviation mistakes, using a cloud-database brand name instead of the underlying engine type, or copy-pasting driver class names into the jdbcType field.","solutions":["Replace jdbcType with one of the map's keys exactly (lowercase), as listed in the exception message.","For unsupported engines, set driverClassName and driverJars explicitly instead of jdbcType.","Normalize user input with toLowerCase() before assigning jdbcType."],"exampleFix":"// before\n.setJdbcType(\"MariaDB\")\n// after\n.setJdbcType(\"mysql\") // or .setDriverClassName(\"org.mariadb.jdbc.Driver\")","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"mysql\", \"postgresql\", \"oracle\", \"mssql\"); // JDBC_DRIVER_MAP keys\nif (jdbcType != null && !allowed.contains(jdbcType.toLowerCase())) {\n  throw new IllegalArgumentException(\"jdbcType must be one of \" + allowed);\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"JDBC type must be one of\")) {\n    throw new IllegalStateException(\"Unsupported jdbcType '\" + jdbcType + \"'; valid: \" + e.getMessage(), e);\n  }\n  throw e;\n}","preventionTips":["Expose a dropdown/enum of valid jdbcType values in tooling instead of free text.","Map brand names (MariaDB, Aurora) to engine types before setting the field.","Log JDBC_DRIVER_MAP.keySet() in docs/onboarding."],"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"}