Skip to content

Commit

Permalink
Fixed the connection leak in Database Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathGOD7 committed Dec 26, 2024
1 parent 626e617 commit 25fdf1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "io.github.deathgod7.SE7ENLib"
version = "1.1.1"
version = "1.1.2-rc1"
description = "A lib to aid in development for my java stuff."

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,20 @@ public DatabaseInfo getDbInfo() {
* @return {@link Boolean}
*/
public boolean isConnected() {
return (this.getConnection() != null);
if (_dbInfo.getDbType() == DatabaseType.SQLite || _dbInfo.getDbType() == DatabaseType.MySQL) {
try (Connection con = (Connection) this.getConnection()) {
return con != null;
} catch (SQLException ex) {
Logger.log("[CONNECTION CHECK ERROR] " + ex.getMessage());
return false;
}
}
else if (_dbInfo.getDbType() == DatabaseType.MongoDB) {
return this.getMongoDB().isConnected();
}
else {
return false;
}
}

private boolean debugMode = false;
Expand Down

0 comments on commit 25fdf1c

Please sign in to comment.