Upgraded class instanciate method.

This commit is contained in:
Christian P. MOMON 2024-08-14 17:20:41 +02:00
parent 839689e6c6
commit f11b3c7ec3

View file

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