Skip to content
Snippets Groups Projects
Commit 7a572155 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

DOC: Documentation and small refactoring.

parent 6462af44
No related branches found
No related tags found
2 merge requests!41REL: update changelog, bump version of pom.xml, update DEPENDENCIES,!19More "semantic-versioning" compatible check for back-end schema
Pipeline #9142 passed
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment