Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/subside/plugins/koth/datatable/MySQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ public class MySQL implements IDatabase {
public MySQL(KothPlugin plugin){
this.plugin = plugin;
}

public Connection getConnection() throws SQLException {
if(connection != null && !connection.isClosed())
if (connection != null && !connection.isClosed())
return connection;

try {
Class.forName("com.mysql.jdbc.Driver");
ConfigHandler.Database cDB = plugin.getConfigHandler().getDatabase();
String url = "//" + cDB.getHost() + ":" + cDB.getPort() + "/" + cDB.getDatabase();
this.connection = DriverManager.getConnection("jdbc:mysql:" + url, cDB.getUsername(), cDB.getPassword());
String url = "//" + cDB.getHost() + ":" + cDB.getPort() + "/" + cDB.getDatabase();
// Add autoReconnect=true to the JDBC URL
this.connection = DriverManager.getConnection("jdbc:mysql:" + url + "?autoReconnect=true", cDB.getUsername(), cDB.getPassword());
return this.connection;
} catch (ClassNotFoundException e) {
plugin.getLogger().log(Level.SEVERE, "Couldn't find the MySQL library!", e);
}

return null;
}

}