diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/DatabaseConnectionPool.java b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/DatabaseConnectionPool.java index e93e33aff500f86a94cd3c03a630163eb28ac090..997de3141db6fd49ac510fa61150a2d16e7d5416 100644 --- a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/DatabaseConnectionPool.java +++ b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/DatabaseConnectionPool.java @@ -175,6 +175,15 @@ class DatabaseConnectionPool { logger.debug("####################"); } + /** + * Check the version of the SQL server's database. + * + * <p>Current behaviour: Major versions must match and the database's minor version must be at + * least the expected minor version as defined in {@link + * ServerProperties.KEY_MYSQL_SCHEMA_VERSION}. + * + * <p>@todo Patch versions are not handled yet. + */ private static void checkVersion(final Connection con) throws SQLException, ConnectionException, CaosDBException { try { @@ -186,9 +195,9 @@ class DatabaseConnectionPool { final String expected_minor = expected_version[1]; con.setReadOnly(false); - final PreparedStatement prepareStatement = con.prepareStatement("SELECT CaosDBVersion()"); + final PreparedStatement prepared = con.prepareStatement("SELECT CaosDBVersion()"); try { - final ResultSet executeQuery = prepareStatement.executeQuery(); + final ResultSet executeQuery = prepared.executeQuery(); if (executeQuery.next()) { final String actual_version = executeQuery.getString(1).toLowerCase(); @@ -200,13 +209,13 @@ class DatabaseConnectionPool { if (Integer.parseInt(actual_major.replace("v", "")) < Integer.parseInt(expected_major.replace("v", ""))) { logger.error( - "Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the mysql backend.\n\n", + "Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the MySQL backend.\n\n", expected_major, expected_minor, actual_version); } else { logger.error( - "Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the server.\n\n", + "Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the CaosDB server.\n\n", expected_major, expected_minor, actual_version); @@ -216,7 +225,7 @@ class DatabaseConnectionPool { if (!Objects.equal(actual_minor, expected_minor)) { if (Integer.parseInt(actual_minor) < Integer.parseInt(expected_minor)) { logger.error( - "Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the mysql backend.\n\n", + "Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the MySQL backend.\n\n", expected_major, expected_minor, actual_version); @@ -225,7 +234,7 @@ class DatabaseConnectionPool { } } else { logger.error( - "Version of the MySQL schema could not be determined. This probably means, that the version is too old.\n\tExpected: {}.{}\n\tActual: unknown\nPlease upgrade the mysql backend.\n\n", + "Version of the MySQL schema could not be determined. This probably means that the version is too old.\n\tExpected: {}.{}\n\tActual: unknown\nPlease upgrade the MySQL backend.\n\n", expected_major, expected_minor); System.exit(1);