Cleaned up TPSTable column variables

This commit is contained in:
Rsl1122 2017-08-23 14:09:58 +03:00
parent 3ea691f4d0
commit 5ee7b9de35
2 changed files with 21 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.data.TPS; import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.database.DBUtils; import main.java.com.djrapitops.plan.database.DBUtils;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.sql.Select;
import main.java.com.djrapitops.plan.database.sql.Sql; import main.java.com.djrapitops.plan.database.sql.Sql;
import main.java.com.djrapitops.plan.database.sql.TableSqlParser; import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.Benchmark;
@ -24,14 +25,14 @@ import java.util.List;
*/ */
public class TPSTable extends Table { public class TPSTable extends Table {
private final String columnServerID; //TODO private final String columnServerID = "server_id"; //TODO
private final String columnDate; private final String columnDate = "date";
private final String columnTPS; private final String columnTPS = "tps";
private final String columnPlayers; private final String columnPlayers = "players_online";
private final String columnCPUUsage; private final String columnCPUUsage = "cpu_usage";
private final String columnRAMUsage; private final String columnRAMUsage = "ram_usage";
private final String columnEntities; private final String columnEntities = "entities";
private final String columnChunksLoaded; private final String columnChunksLoaded = "chunks_loaded";
/** /**
* @param db * @param db
@ -39,14 +40,6 @@ public class TPSTable extends Table {
*/ */
public TPSTable(SQLDB db, boolean usingMySQL) { public TPSTable(SQLDB db, boolean usingMySQL) {
super("plan_tps", db, usingMySQL); super("plan_tps", db, usingMySQL);
columnServerID = "server_id";
columnDate = "date";
columnTPS = "tps";
columnPlayers = "players_online";
columnCPUUsage = "cpu_usage";
columnRAMUsage = "ram_usage";
columnEntities = "entities";
columnChunksLoaded = "chunks_loaded";
} }
@Override @Override
@ -72,7 +65,7 @@ public class TPSTable extends Table {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try { try {
statement = prepareStatement("SELECT * FROM " + tableName); statement = prepareStatement(Select.all(tableName).toString());
set = statement.executeQuery(); set = statement.executeQuery();
while (set.next()) { while (set.next()) {
long date = set.getLong(columnDate); long date = set.getLong(columnDate);

View File

@ -5,6 +5,8 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.sql.Sql;
import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
/** /**
* //TODO Class Javadoc Comment * //TODO Class Javadoc Comment
@ -29,6 +31,14 @@ public class UserInfoTable extends UserIDTable {
@Override @Override
public boolean createTable() { public boolean createTable() {
return false; return createTable(TableSqlParser.createTable(tableName)
.column(columnUserID, Sql.INT).notNull()
.column(columnRegistered, Sql.LONG).notNull()
.column(columnOP, Sql.BOOL).notNull().defaultValue(false)
.column(columnBanned, Sql.BOOL).notNull().defaultValue(false)
.column(columnServerID, Sql.INT).notNull()
.foreignKey(columnUserID, usersTable.getTableName(), usersTable.getColumnID())
.foreignKey(columnServerID, serverTable.getTableName(), serverTable.getColumnID())
.toString());
} }
} }