diff --git a/src/fr/devinsy/statoolinfos/util/sql/SQLUtils.java b/src/fr/devinsy/statoolinfos/util/sql/SQLUtils.java index 10ada04..6ce15bf 100644 --- a/src/fr/devinsy/statoolinfos/util/sql/SQLUtils.java +++ b/src/fr/devinsy/statoolinfos/util/sql/SQLUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Christian Pierre MOMON + * Copyright (C) 2020-2024 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -18,6 +18,7 @@ */ package fr.devinsy.statoolinfos.util.sql; +import java.lang.reflect.InvocationTargetException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -192,23 +193,12 @@ public final class SQLUtils } else { - Class.forName("com.mysql.jdbc.Driver").newInstance(); + Class.forName("com.mysql.jdbc.Driver").getConstructor().newInstance(); result = DriverManager.getConnection(serverUrl + databaseName + "?useUnicode=true&characterEncoding=utf8", login, password); } } - catch (SQLException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } - catch (InstantiationException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } - catch (IllegalAccessException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } - catch (ClassNotFoundException exception) + catch (SQLException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException + | ClassNotFoundException exception) { throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); }