Skip to content

Commit d4c36ef

Browse files
committed
Changes to mysql
1 parent 6b5f9bb commit d4c36ef

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

AdvancedCore/src/com/bencodez/advancedcore/api/user/userstorage/mysql/MySQL.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ public ArrayList<Column> load(String key) {
123123
if (tablePrefix != null) {
124124
name = tablePrefix + tableName;
125125
}
126-
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads);
126+
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads) {
127+
128+
@Override
129+
public void severe(String string) {
130+
plugin.getLogger().severe(string);
131+
}
132+
133+
@Override
134+
public void debug(SQLException e) {
135+
plugin.debug(e);
136+
}
137+
};
127138
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
128139
plugin.getLogger().warning("Failed to connect to MySQL");
129140
}

AdvancedCore/src/com/bencodez/advancedcore/api/user/userstorage/mysql/api/MySQL.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.bencodez.advancedcore.api.user.userstorage.mysql.api;
22

3+
import java.sql.SQLException;
34
import java.util.concurrent.ExecutorService;
45
import java.util.concurrent.Executors;
56

6-
public class MySQL {
7+
public abstract class MySQL {
78

89
private ConnectionManager connectionManager;
910
private int maxConnections;
@@ -64,4 +65,8 @@ public ConnectionManager getConnectionManager() {
6465
public ExecutorService getThreadPool() {
6566
return threadPool;
6667
}
68+
69+
public abstract void severe(String string);
70+
71+
public abstract void debug(SQLException e);
6772
}

AdvancedCore/src/com/bencodez/advancedcore/api/user/userstorage/mysql/api/queries/Query.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.HashMap;
77
import java.util.Map.Entry;
88

9-
import com.bencodez.advancedcore.AdvancedCorePlugin;
109
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL;
1110

1211
public class Query {
@@ -153,11 +152,11 @@ public int executeUpdate() throws SQLException {
153152
return num;
154153

155154
} catch (SQLException e) {
156-
AdvancedCorePlugin.getInstance().getLogger().severe("Failed to send query: " + this.sql);
155+
mysql.severe("Failed to send query: " + this.sql);
157156
if (!e.getMessage().contains("Duplicate entry")) {
158157
e.printStackTrace();
159158
} else {
160-
AdvancedCorePlugin.getInstance().debug(e);
159+
mysql.debug(e);
161160
}
162161

163162
}

0 commit comments

Comments
 (0)