Fix create statements

This commit is contained in:
GeorgH93 2018-04-28 15:04:37 +02:00
parent 1a6c664719
commit f4b816b24f
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
2 changed files with 11 additions and 11 deletions

View File

@ -6,13 +6,13 @@
<version>1.17.8-SNAPSHOT</version> <version>1.17.8-SNAPSHOT</version>
<scm> <scm>
<connection>scm:git:git@github.com:GeorgH93/Bukkit_Minepacks.git</connection> <connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>
<developerConnection>scm:git:git@github.com:GeorgH93/Bukkit_Minepacks.git</developerConnection> <developerConnection>scm:git:git@github.com:GeorgH93/Minepacks.git</developerConnection>
<url>git@github.com:GeorgH93/Bukkit_Minepacks.git</url> <url>git@github.com:GeorgH93/Minepacks.git</url>
</scm> </scm>
<issueManagement> <issueManagement>
<system>GitHub</system> <system>GitHub</system>
<url>https://github.com/GeorgH93/Bukkit_Minepacks/issues</url> <url>https://github.com/GeorgH93/Minepacks/issues</url>
</issueManagement> </issueManagement>
<ciManagement> <ciManagement>
<system>jenkins</system> <system>jenkins</system>

View File

@ -23,9 +23,7 @@
import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariConfig;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
public class MySQL extends SQL public class MySQL extends SQL
{ {
@ -56,18 +54,20 @@ protected void updateQuerysForDialect()
@Override @Override
protected void checkDB() protected void checkDB()
{ {
try(Connection connection = getConnection(); Statement stmt = connection.createStatement()) try(Connection connection = getConnection())
{ {
if(useUUIDs) if(useUUIDs)
{ {
DBTools.updateDB(connection, "CREATE TABLE IF NOT EXISTS `" + tablePlayers + "` (`" + fieldPlayerID + "` INT UNSIGNED NOT NULL AUTO_INCREMENT,`" + fieldName + "` CHAR(16) NOT NULL,`" + fieldUUID + "` CHAR(36) UNIQUE, PRIMARY KEY (`" + fieldPlayerID + "`));"); DBTools.updateDB(connection, "CREATE TABLE `" + tablePlayers + "` (\n`" + fieldPlayerID + "` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n`" + fieldName + "` CHAR(16) NOT NULL,\n`"
+ fieldUUID + "` CHAR(36) DEFAULT NULL,\nPRIMARY KEY (`" + fieldPlayerID + "`),\nUNIQUE INDEX `" + fieldUUID + "_UNIQUE` (`" + fieldUUID + "`)\n);");
} }
else else
{ {
DBTools.updateDB(connection, "CREATE TABLE IF NOT EXISTS `" + tablePlayers + "` (`" + fieldPlayerID + "` INT UNSIGNED NOT NULL AUTO_INCREMENT,`" + fieldName + "` CHAR(16) NOT NULL UNIQUE, PRIMARY KEY (`" + fieldPlayerID + "`));"); DBTools.updateDB(connection, "CREATE TABLE `" + tablePlayers + "` (\n`" + fieldPlayerID + "` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n`" + fieldName + "` CHAR(16) NOT NULL,\n"
+ "PRIMARY KEY (`" + fieldPlayerID + "`),\nUNIQUE INDEX `" + fieldName + "_UNIQUE` (`" + fieldName + "`)\n);");
} }
DBTools.updateDB(connection, "CREATE TABLE IF NOT EXISTS `" + tableBackpacks + "` (`" + fieldBPOwner + "` INT UNSIGNED NOT NULL, `" + fieldBPITS + "` BLOB, `" DBTools.updateDB(connection, "CREATE TABLE `" + tableBackpacks + "` (\n`" + fieldBPOwner + "` INT UNSIGNED NOT NULL,\n`" + fieldBPITS + "` BLOB,\n`"
+ fieldBPVersion + "` INT DEFAULT 0, " + ((maxAge > 0) ? "`" + fieldBPLastUpdate + "` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, " : "") + "PRIMARY KEY (`" + fieldBPOwner + "`));"); + fieldBPVersion + "` INT DEFAULT 0,\n" + ((maxAge > 0) ? "`" + fieldBPLastUpdate + "` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n" : "") + "PRIMARY KEY (`" + fieldBPOwner + "`)\n);");
} }
catch (SQLException e) catch (SQLException e)
{ {