Wrap unimportant sql migrations in try..catch (#755)

This commit is contained in:
Luck 2018-02-16 12:13:15 +00:00
parent b8c5c60ece
commit 4fda89d5c8
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -205,15 +205,20 @@ public class SqlDao extends AbstractDao {
}
// migrations
if (!(this.provider instanceof SQLiteConnectionFactory) && !(this.provider instanceof PostgreConnectionFactory)) {
try (Connection connection = this.provider.getConnection()) {
try (Statement s = connection.createStatement()) {
s.execute(this.prefix.apply("ALTER TABLE {prefix}actions MODIFY COLUMN actor_name VARCHAR(100)"));
s.execute(this.prefix.apply("ALTER TABLE {prefix}actions MODIFY COLUMN action VARCHAR(300)"));
try {
if (!(this.provider instanceof SQLiteConnectionFactory) && !(this.provider instanceof PostgreConnectionFactory)) {
try (Connection connection = this.provider.getConnection()) {
try (Statement s = connection.createStatement()) {
s.execute(this.prefix.apply("ALTER TABLE {prefix}actions MODIFY COLUMN actor_name VARCHAR(100)"));
s.execute(this.prefix.apply("ALTER TABLE {prefix}actions MODIFY COLUMN action VARCHAR(300)"));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
this.plugin.getLog().severe("Error occurred whilst initialising the database.");
e.printStackTrace();