Update EconomyStorageBackendMySQL.java

This commit is contained in:
AppleDash 2017-07-14 01:11:50 -04:00 committed by GitHub
parent f54a43437d
commit c7f58edf44

View File

@ -34,8 +34,7 @@ public class EconomyStorageBackendMySQL extends EconomyStorageBackendCaching {
schemaVersion = -1; schemaVersion = -1;
} else { } else {
PreparedStatement ps = conn.prepareStatement(String.format("SELECT `val` FROM `%s` WHERE `key` = 'schema_version'", dbConn.getTable("saneeconomy_schema"))); PreparedStatement ps = conn.prepareStatement(String.format("SELECT `val` FROM `%s` WHERE `key` = 'schema_version'", dbConn.getTable("saneeconomy_schema")));
ps.executeQuery(); ResultSet rs = ps.executeQuery();
ResultSet rs = ps.getResultSet();
if (!rs.next()) { if (!rs.next()) {
throw new RuntimeException("Invalid database schema!"); throw new RuntimeException("Invalid database schema!");
@ -46,7 +45,7 @@ public class EconomyStorageBackendMySQL extends EconomyStorageBackendCaching {
if (schemaVersion == -1) { if (schemaVersion == -1) {
conn.prepareStatement(String.format("CREATE TABLE IF NOT EXISTS `%s` (`key` VARCHAR(32) PRIMARY KEY, `val` TEXT)", dbConn.getTable("saneeconomy_schema"))).executeUpdate(); conn.prepareStatement(String.format("CREATE TABLE IF NOT EXISTS `%s` (`key` VARCHAR(32) PRIMARY KEY, `val` TEXT)", dbConn.getTable("saneeconomy_schema"))).executeUpdate();
conn.prepareStatement(String.format("REPLACE INTO %s (`key`, `val`) VALUES ('schema_version', 2)", dbConn.getTable("saneeconomy_schema"))); conn.prepareStatement(String.format("REPLACE INTO %s (`key`, `val`) VALUES ('schema_version', 2)", dbConn.getTable("saneeconomy_schema"))).executeUpdate();
conn.prepareStatement(String.format("CREATE TABLE `%s` (unique_identifier VARCHAR(128) PRIMARY KEY, balance DECIMAL(18, 2))", dbConn.getTable("saneeconomy_balances"))).executeUpdate(); conn.prepareStatement(String.format("CREATE TABLE `%s` (unique_identifier VARCHAR(128) PRIMARY KEY, balance DECIMAL(18, 2))", dbConn.getTable("saneeconomy_balances"))).executeUpdate();
schemaVersion = 2; schemaVersion = 2;
} }