Suppress error if added column already exists

This commit is contained in:
Georg 2015-03-17 16:44:22 +01:00
parent 50a2936b8d
commit 2c73e5d33e
3 changed files with 5 additions and 29 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId> <groupId>at.pcgamingfreaks</groupId>
<artifactId>MinePacks</artifactId> <artifactId>MinePacks</artifactId>
<version>1.2</version> <version>1.2.1</version>
<repositories> <repositories>
<repository> <repository>
<id>in-project</id> <id>in-project</id>

View File

@ -114,26 +114,14 @@ private void CheckDB()
{ {
stmt.execute("ALTER TABLE `" + Table_Players + "` ADD COLUMN `uuid` CHAR(32) UNIQUE;"); stmt.execute("ALTER TABLE `" + Table_Players + "` ADD COLUMN `uuid` CHAR(32) UNIQUE;");
} }
catch(SQLException e) catch(SQLException e) { }
{
if(e.getErrorCode() != 1060)
{
e.printStackTrace();
}
}
} }
stmt.execute("CREATE TABLE IF NOT EXISTS `" + Table_Backpacks + "` (`owner` INT UNSIGNED NOT NULL, `itemstacks` BLOB, PRIMARY KEY (`owner`));"); stmt.execute("CREATE TABLE IF NOT EXISTS `" + Table_Backpacks + "` (`owner` INT UNSIGNED NOT NULL, `itemstacks` BLOB, PRIMARY KEY (`owner`));");
try try
{ {
stmt.execute("ALTER TABLE `" + Table_Backpacks + "` ADD COLUMN `version` INT DEFAULT 0;"); stmt.execute("ALTER TABLE `" + Table_Backpacks + "` ADD COLUMN `version` INT DEFAULT 0;");
} }
catch(SQLException e) catch(SQLException e) { }
{
if(e.getErrorCode() != 1060)
{
e.printStackTrace();
}
}
stmt.close(); stmt.close();
} }
catch (SQLException e) catch (SQLException e)

View File

@ -120,26 +120,14 @@ private void CheckDB()
{ {
stmt.execute("ALTER TABLE `" + Table_Players + "` ADD COLUMN `uuid` CHAR(32) UNIQUE;"); stmt.execute("ALTER TABLE `" + Table_Players + "` ADD COLUMN `uuid` CHAR(32) UNIQUE;");
} }
catch(SQLException e) catch(SQLException e) { }
{
if(e.getErrorCode() != 1060)
{
e.printStackTrace();
}
}
} }
stmt.execute("CREATE TABLE IF NOT EXISTS `" + Table_Backpacks + "` (`owner` INT UNSIGNED PRIMARY KEY, `itemstacks` BLOB);"); stmt.execute("CREATE TABLE IF NOT EXISTS `" + Table_Backpacks + "` (`owner` INT UNSIGNED PRIMARY KEY, `itemstacks` BLOB);");
try try
{ {
stmt.execute("ALTER TABLE `" + Table_Backpacks + "` ADD COLUMN `version` INT DEFAULT 0;"); stmt.execute("ALTER TABLE `" + Table_Backpacks + "` ADD COLUMN `version` INT DEFAULT 0;");
} }
catch(SQLException e) catch(SQLException e) { }
{
if(e.getErrorCode() != 1060)
{
e.printStackTrace();
}
}
stmt.close(); stmt.close();
} }
catch (SQLException e) catch (SQLException e)