diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java index dfbf75bedd..0c4e25d6ac 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java @@ -365,7 +365,13 @@ public class GenerationTool { if (!properties.containsKey("password")) properties.put("password", defaultString(j.getPassword())); - setConnection(driver.newInstance().connect(defaultString(j.getUrl()), properties)); + Connection c = driver.newInstance().connect(defaultString(j.getUrl()), properties); + + // [#12951] Some drivers may (illegally) return null if the URL is incorrect? + if (c == null) + throw new SQLException("Cannot connect to database using JDBC URL: " + j.getUrl() + ". Please review your JDBC configuration in the code generator configuration."); + + setConnection(c); if (j.getInitScript() != null) for (String sql : j.getInitScript().split(defaultIfBlank(j.getInitSeparator(), ";")))