Skip to content

Commit

Permalink
Merge pull request #34 from Grubnest/hotfix-database-manager
Browse files Browse the repository at this point in the history
Database Manager Hotfix
  • Loading branch information
Wyzards authored Jun 6, 2022
2 parents 266d2a1 + 6dd4e89 commit b8b56d2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 340 deletions.
302 changes: 0 additions & 302 deletions src/main/java/com/grubnest/game/core/PluginMessage.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.grubnest.game.core.databasehandler;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Objects;

/**
* Handles connection access for all other Grubnest Plugins
*
* @author Theeef
* @version 1.0 at 6/6/2022
*/
public class DatabaseManager {

private static DatabaseManager instance;
private final MySQL mysql;

private DatabaseManager() {
this.mysql = new MySQL(MySQLData.dataInitializer());
}

/**
* Gets the Singleton instance of the DatabaseManager
*
* @return the database manager
*/
public static DatabaseManager getInstance() {
return Objects.requireNonNullElseGet(instance, () -> instance = new DatabaseManager());
}

/**
* Gets a connection from the ConnectionPool
*
* @return a connection
* @throws SQLException
*/
public Connection getConnection() throws SQLException {
return this.mysql.getConnection();
}

/**
* Gets the MySQL connection
*
* @return mysql object
*/
public MySQL getMySQL() {
return this.mysql;
}

}
Loading

0 comments on commit b8b56d2

Please sign in to comment.