diff --git a/src/main/java/servlets/Setup.java b/src/main/java/servlets/Setup.java index 525b49ff5..9bf47d330 100644 --- a/src/main/java/servlets/Setup.java +++ b/src/main/java/servlets/Setup.java @@ -216,10 +216,18 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) testJdbcUrl = connectionURL + "?connectTimeout=5000"; } - try (Connection conn = DriverManager.getConnection(testJdbcUrl, dbUser, dbPass)) { - connectionSuccess = true; - log.debug("Database connection successful"); + try { + Class.forName(driverType); + try (Connection conn = DriverManager.getConnection(testJdbcUrl, dbUser, dbPass)) { + connectionSuccess = true; + log.debug("Database connection successful"); + } + } catch (ClassNotFoundException e) { + log.error("Could not load JDBC driver: " + driverType, e); + htmlOutput = + bundle.getString("generic.text.setup.connection.failed") + + ": Could not load JDBC driver"; } catch (SQLException e) { htmlOutput += bundle.getString("generic.text.setup.connection.failed") + e.getMessage();