-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Grubnest/hotfix-database-manager
Database Manager Hotfix
- Loading branch information
Showing
5 changed files
with
54 additions
and
340 deletions.
There are no files selected for viewing
302 changes: 0 additions & 302 deletions
302
src/main/java/com/grubnest/game/core/PluginMessage.java
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
src/main/java/com/grubnest/game/core/databasehandler/DatabaseManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
Oops, something went wrong.