diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java index 51ff3a6ac..7e54b953b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.database.databases.sql.processing; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.PreparedStatement; @@ -18,29 +19,36 @@ import java.sql.SQLException; public abstract class ExecStatement { private final String sql; + private final boolean devMode; public ExecStatement(String sql) { this.sql = sql; - if (Settings.DEV_MODE.isTrue()) { - Log.debug("Execute Statement: " + sql); - } + devMode = Settings.DEV_MODE.isTrue(); } public boolean execute(PreparedStatement statement) throws SQLException { + Benchmark.start(sql); try { prepare(statement); return statement.executeUpdate() > 0; } finally { statement.close(); + if (devMode) { + Log.debug(Benchmark.stopAndFormat(sql)); + } } } public void executeBatch(PreparedStatement statement) throws SQLException { + Benchmark.start(sql + " (Batch)"); try { prepare(statement); statement.executeBatch(); } finally { statement.close(); + if (devMode) { + Log.debug(Benchmark.stopAndFormat(sql + " (Batch)")); + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java index 675864c9d..a759465b4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.database.databases.sql.processing; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.PreparedStatement; @@ -20,6 +21,7 @@ public abstract class QueryStatement { private final String sql; private final int fetchSize; + private boolean devMode; public QueryStatement(String sql) { this(sql, 10); @@ -27,13 +29,12 @@ public abstract class QueryStatement { public QueryStatement(String sql, int fetchSize) { this.sql = sql; - if (Settings.DEV_MODE.isTrue()) { - Log.debug("Query Statement: " + sql); - } + devMode = Settings.DEV_MODE.isTrue(); this.fetchSize = fetchSize; } public T executeQuery(PreparedStatement statement) throws SQLException { + Benchmark.start(sql); try { statement.setFetchSize(fetchSize); prepare(statement); @@ -42,6 +43,9 @@ public abstract class QueryStatement { } } finally { statement.close(); + if (devMode) { + Log.debug(Benchmark.stopAndFormat(sql)); + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java index 4e23ed6a4..d1ed92bf9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java @@ -37,17 +37,11 @@ public abstract class Table { * * @param name Name of the table in the db. * @param db Database to use. - * @param usingMySQL Is the database using MySQL? */ - @Deprecated - public Table(String name, SQLDB db, boolean usingMySQL) { - this(name, db); - } - public Table(String name, SQLDB db) { this.tableName = name; this.db = db; - this.usingMySQL = db.isUsingMySQL(); + this.usingMySQL = db != null && db.isUsingMySQL(); } public abstract void createTable() throws DBInitException; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java index 4b4342044..3cb8d7c25 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/TabsElement.java @@ -19,7 +19,7 @@ public class TabsElement { this.tabs = tabs; } - public String toHtml() { + public String[] toHtml() { StringBuilder nav = new StringBuilder(); StringBuilder content = new StringBuilder(); @@ -36,13 +36,13 @@ public class TabsElement { .append(navText).append(""); content.append("
") - .append(contentHtml).append("
"); + .append(contentHtml).append(""); first = false; } content.append(""); nav.append(""); - return nav.toString() + content.toString(); + return new String[]{nav.toString(), content.toString()}; } public static class Tab {