From 7a57215507446d86a5b516c658bc5ba17560525b Mon Sep 17 00:00:00 2001 From: Daniel Hornung <d.hornung@indiscale.com> Date: Wed, 23 Jun 2021 13:33:48 +0200 Subject: [PATCH] DOC: Documentation and small refactoring. --- .../MySQL/DatabaseConnectionPool.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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 e93e33af..997de314 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); -- GitLab