{"record":{"id":"96748ad096af3634","repo":"apache/beam","slug":"if-jdbc-type-is-not-specified-then-driver-class-name-and","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/JdbcReadSchemaTransformProvider.java","lineNumber":413,"sourceCode":"    @Nullable\n    public abstract String getUsername();\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(\"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) {","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java#L395-L431","documentation":"The JdbcReadSchemaTransformProvider validator requires enough information to pick a JDBC driver. If none of jdbcType, driverClassName, or driverJars is present, it cannot load a driver and throws this IllegalArgumentException immediately after the URL check.","triggerScenarios":"Calling validate() (directly, via from(), or from SqlServerReadSchemaTransform) with a configuration where jdbcType is null/empty AND driverClassName is null/empty AND driverJars is null/empty.","commonSituations":"Users new to the SchemaTransform API provide only URL/query/location and expect the driver to be auto-detected; config migration dropped the driver fields.","solutions":["Set jdbcType to a supported value from JDBC_DRIVER_MAP (e.g. mysql, postgresql, oracle, mssql).","Or set driverClassName (e.g. com.mysql.cj.jdbc.Driver) together with driverJars pointing to the driver artifact.","Check the serialized config map keys for typos like driverClass vs driverClassName."],"exampleFix":"// before\nbuilder().setJdbcUrl(url).setLocation(\"table1\")\n// after\nbuilder().setJdbcUrl(url).setLocation(\"table1\").setJdbcType(\"postgresql\")","handlingStrategy":"validation","validationCode":"boolean hasType = config.getJdbcType() != null && !config.getJdbcType().isEmpty();\nboolean hasDriver = (config.getDriverClassName() != null && !config.getDriverClassName().isEmpty())\n    && (config.getDriverJars() != null && !config.getDriverJars().isEmpty());\nif (!hasType && !hasDriver) {\n  throw new IllegalArgumentException(\"Set either jdbcType or driverClassName+driverJars\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"If JDBC type is not specified\")) {\n    throw new IllegalStateException(\"Driver configuration missing: set jdbcType or driverClassName+driverJars\", e);\n  }\n  throw e;\n}","preventionTips":["Default jdbcType in your config layer per environment.","Check for key typos (driverClassName vs driverClass) when migrating configs.","Always ship driverJars alongside a custom driverClassName."],"tags":["jdbc","java","validation","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-20T03:17:13.778Z"}