From 9af7d689b25b9da78e5ec3f3d0cffe4186b38e5c Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Sun, 7 Jun 2020 13:14:56 +0300 Subject: [PATCH] H2 user and pass field. Deprecated warning. - Fixes move from h2 to mysql Affects issues: - #1472 - Fixed #1111 --- .../commands/subcommands/manage/ManageMoveCommand.java | 10 ---------- .../plan/settings/config/paths/DatabaseSettings.java | 2 ++ .../com/djrapitops/plan/storage/database/H2DB.java | 6 ++++-- Plan/common/src/main/resources/assets/plan/config.yml | 3 +++ .../djrapitops/plan/settings/ConfigSettingKeyTest.java | 2 ++ 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/manage/ManageMoveCommand.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/manage/ManageMoveCommand.java index fe29a537f..232d345be 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/manage/ManageMoveCommand.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/manage/ManageMoveCommand.java @@ -91,16 +91,6 @@ public class ManageMoveCommand extends CommandNode { return; } - // Temporarily disabled due to issues - boolean transferH2 = fromDB == DBType.H2 || toDB == DBType.H2; - boolean transferMySQL = fromDB == DBType.MYSQL || toDB == DBType.MYSQL; - - if (transferH2 && transferMySQL) { - sender.sendMessage("§cDirect transfers between H2 and MySQL are temporarily disabled due to a bug: See the issue link for workaround"); - sender.sendLink("Link to Github Issue", "https://github.com/plan-player-analytics/Plan/issues/1111"); - return; - } - try { final Database fromDatabase = dbSystem.getActiveDatabaseByType(fromDB); final Database toDatabase = dbSystem.getActiveDatabaseByType(toDB); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/DatabaseSettings.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/DatabaseSettings.java index 8db2b787c..9f23970b2 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/DatabaseSettings.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/DatabaseSettings.java @@ -32,6 +32,8 @@ public class DatabaseSettings { public static final Setting MYSQL_HOST = new StringSetting("Database.MySQL.Host"); public static final Setting MYSQL_PORT = new StringSetting("Database.MySQL.Port", NumberUtils::isParsable); public static final Setting MYSQL_USER = new StringSetting("Database.MySQL.User"); + public static final Setting H2_USER = new StringSetting("Database.H2.User"); + public static final Setting H2_PASS = new StringSetting("Database.H2.Password"); public static final Setting MYSQL_PASS = new StringSetting("Database.MySQL.Password"); public static final Setting MYSQL_DATABASE = new StringSetting("Database.MySQL.Database"); public static final Setting MYSQL_LAUNCH_OPTIONS = new StringSetting("Database.MySQL.Launch_options"); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/H2DB.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/H2DB.java index 3185033cc..a0414894c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/H2DB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/H2DB.java @@ -86,8 +86,8 @@ public class H2DB extends SQLDB { } private Connection getConnectionFor(String dbFilePath) throws SQLException { - String username = config.get(DatabaseSettings.MYSQL_USER); - String password = config.get(DatabaseSettings.MYSQL_PASS); + String username = config.get(DatabaseSettings.H2_USER); + String password = config.get(DatabaseSettings.H2_PASS); JdbcDataSource jdbcDataSource = new JdbcDataSource(); jdbcDataSource.setURL("jdbc:h2:file:" + dbFilePath + ";mode=MySQL;DATABASE_TO_UPPER=false"); @@ -99,6 +99,8 @@ public class H2DB extends SQLDB { private void startConnectionPingTask() { stopConnectionPingTask(); + logger.warn("H2 database is going to be deprecated in version 5.2. It is recommended to move to MySQL or SQLite when possible."); + logger.warn("See https://github.com/plan-player-analytics/Plan/issues/1472 for details"); try { // Maintains Connection. connectionPingTask = runnableFactory.create("DBConnectionPingTask " + getType().getName(), diff --git a/Plan/common/src/main/resources/assets/plan/config.yml b/Plan/common/src/main/resources/assets/plan/config.yml index 30be966d4..d32a4f363 100644 --- a/Plan/common/src/main/resources/assets/plan/config.yml +++ b/Plan/common/src/main/resources/assets/plan/config.yml @@ -34,6 +34,9 @@ Database: Database: Plan # Launch options to append after mysql driver address Launch_options: ?rewriteBatchedStatements=true&useSSL=false + H2: + User: root + Password: minecraft # ----------------------------------------------------- # More information about SSL Certificate Settings: # https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/SSL-Certificate-%28HTTPS%29-Set-Up diff --git a/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java b/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java index 84fd6738a..b27f17d9b 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java @@ -109,6 +109,8 @@ public class ConfigSettingKeyTest { settings.remove(PluginSettings.PROXY_COPY_CONFIG); settings.remove(DatabaseSettings.TYPE); settings.remove(DisplaySettings.WORLD_ALIASES); + settings.remove(DatabaseSettings.H2_USER); + settings.remove(DatabaseSettings.H2_PASS); return settings; }