Skip to content

Commit

Permalink
Changes to mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCodez committed May 31, 2021
1 parent 6b5f9bb commit d4c36ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,18 @@ public ArrayList<Column> load(String key) {
if (tablePrefix != null) {
name = tablePrefix + tableName;
}
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads);
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads) {

@Override
public void severe(String string) {
plugin.getLogger().severe(string);
}

@Override
public void debug(SQLException e) {
plugin.debug(e);
}
};
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
plugin.getLogger().warning("Failed to connect to MySQL");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.bencodez.advancedcore.api.user.userstorage.mysql.api;

import java.sql.SQLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MySQL {
public abstract class MySQL {

private ConnectionManager connectionManager;
private int maxConnections;
Expand Down Expand Up @@ -64,4 +65,8 @@ public ConnectionManager getConnectionManager() {
public ExecutorService getThreadPool() {
return threadPool;
}

public abstract void severe(String string);

public abstract void debug(SQLException e);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.HashMap;
import java.util.Map.Entry;

import com.bencodez.advancedcore.AdvancedCorePlugin;
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL;

public class Query {
Expand Down Expand Up @@ -153,11 +152,11 @@ public int executeUpdate() throws SQLException {
return num;

} catch (SQLException e) {
AdvancedCorePlugin.getInstance().getLogger().severe("Failed to send query: " + this.sql);
mysql.severe("Failed to send query: " + this.sql);
if (!e.getMessage().contains("Duplicate entry")) {
e.printStackTrace();
} else {
AdvancedCorePlugin.getInstance().debug(e);
mysql.debug(e);
}

}
Expand Down

0 comments on commit d4c36ef

Please sign in to comment.