Set up connection pool and enforce usage of it

Attempt to initialize connection pool on startup until a timeout.
This commit is contained in:
P0nk
2021-04-02 14:20:45 +02:00
parent 05bd668cc2
commit 45331d17b0
4 changed files with 59 additions and 80 deletions

View File

@@ -866,8 +866,13 @@ public class Server {
public void init() {
System.out.println("Cosmic v" + ServerConstants.VERSION + " starting up.\r\n");
if(YamlConfig.config.server.SHUTDOWNHOOK)
if(YamlConfig.config.server.SHUTDOWNHOOK) {
Runtime.getRuntime().addShutdownHook(new Thread(shutdown(false)));
}
if (!DatabaseConnection.initializeConnectionPool()) {
throw new IllegalStateException("Failed to initiate a connection to the database");
}
TimeZone.setDefault(TimeZone.getTimeZone(YamlConfig.config.server.TIMEZONE));