diff --git a/build.gradle b/build.gradle
index a69ddd2c622872e075dcef2f6b759a7c8e7fcc1a..10bd8fd059de0c05558c900f91f8c8ce3f4d1309 100644
--- a/build.gradle
+++ b/build.gradle
@@ -29,18 +29,34 @@ defaultTasks 'generate'
 
 def variants = ['mysql-tomcat', 'mariadb-tomcat', 'postgres-tomcat']
 
-// Note: To compute the sha256, download the XWiki WAR and issue:
-// - Unix: sha256sum <binary name>
-// - Mac: shasum --algorithm 256 <binary name>
+// Notes:
+// - To compute the XWiki sha256, download the XWiki WAR and issue:
+//   - Unix: sha256sum <binary name>
+//   - Mac: shasum --algorithm 256 <binary name>
+// - To compute the mysql JDBC sha256, get the JAR at https://search.maven.org/artifact/mysql/mysql-connector-java and
+//   do the same as for the XWiki sha256.
+// - To compute the mysql JDBC sha256, get the JAR at
+//   https://search.maven.org/artifact/org.mariadb.jdbc/mariadb-java-client and  do the same as for the XWiki sha256.
+// - Use the JDBC driver versions found in the XWiki POM for the specified versions:
+//   - mysql: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L97 (link for master)
+//   - mariadb: https://github.com/xwiki/xwiki-platform/blob/master/pom.xml#L100 (link for master)
 
 def tokens = [
     '14': [
         xwikiVersion: '14.1',
-        xwikiSha256: '71d739098e9edc2f343c7a7c15034cf0651ad8e97f1cb59ae0c979181fc677a3'
+        xwikiSha256: '71d739098e9edc2f343c7a7c15034cf0651ad8e97f1cb59ae0c979181fc677a3',
+        mysqlJDBCVersion: '8.0.28',
+        mysqlJDBCSha256: 'a00ccdf537ff50e50067b989108c2235197ffb65e197149bbb669db843cd1c3e',
+        mariadbJDBCVersion: '3.0.3',
+        mariadbJDBCSha256: '613086a0a20f177dfcf5e227f519272bc6be88bde4011de0f23c533231a7ae05'
     ],
     '13': [
         xwikiVersion: '13.10.3',
-        xwikiSha256: 'f4f13dcab88baffb0e62fccc5d6375a6d023e4ac7414c502375dd1e8d503cbbd'
+        xwikiSha256: 'f4f13dcab88baffb0e62fccc5d6375a6d023e4ac7414c502375dd1e8d503cbbd',
+        mysqlJDBCVersion: '8.0.28',
+        mysqlJDBCSha256: 'a00ccdf537ff50e50067b989108c2235197ffb65e197149bbb669db843cd1c3e',
+        mariadbJDBCVersion: '3.0.3',
+        mariadbJDBCSha256: '613086a0a20f177dfcf5e227f519272bc6be88bde4011de0f23c533231a7ae05'
     ]
 ]
 
diff --git a/template/Dockerfile b/template/Dockerfile
index cac53e49ed07bba746fd28364fe9b8d1f901e695..310ee77b1ecbbc8472ea5fac1ed188a3c4d431b3 100644
--- a/template/Dockerfile
+++ b/template/Dockerfile
@@ -63,10 +63,8 @@ RUN rm -rf /usr/local/tomcat/webapps/* && \\
 <% if (db == 'mysql') {
   println "# For MYSQL, download the MySQL driver version from the Maven Central repository since there's no up to "
   println "# date Debian repository for it anymore."
-  println "ENV MYSQL_JDBC_VERSION=\"8.0.28\""
-  // Get the SHA256 from the JAR at https://search.maven.org/artifact/mysql/mysql-connector-java and using the
-  // command line defined in build.gradle.
-  println "ENV MYSQL_JDBC_SHA256=\"a00ccdf537ff50e50067b989108c2235197ffb65e197149bbb669db843cd1c3e\""
+  println "ENV MYSQL_JDBC_VERSION=\"$mysqlJDBCVersion\""
+  println "ENV MYSQL_JDBC_SHA256=\"$mysqlJDBCSha256\""
   println "ENV MYSQL_JDBC_PREFIX=\"https://repo1.maven.org/maven2/mysql/mysql-connector-java/\${MYSQL_JDBC_VERSION}\""
   println "ENV MYSQL_JDBC_ARTIFACT=\"mysql-connector-java-\${MYSQL_JDBC_VERSION}.jar\""
   println "ENV MYSQL_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\${MYSQL_JDBC_ARTIFACT}\""
@@ -75,10 +73,8 @@ RUN rm -rf /usr/local/tomcat/webapps/* && \\
 } else if (db == 'mariadb') {
   println "# For MariaDB, download the MariaDB driver version from the Maven Central repository to control the version "
   println "# used."
-  println "ENV MARIADB_JDBC_VERSION=\"3.0.3\""
-  // Get the SHA256 from the JAR at https://search.maven.org/artifact/org.mariadb.jdbc/mariadb-java-client and using the
-  // command line defined in build.gradle.
-  println "ENV MARIADB_JDBC_SHA256=\"613086a0a20f177dfcf5e227f519272bc6be88bde4011de0f23c533231a7ae05\""
+  println "ENV MARIADB_JDBC_VERSION=\"$mariadbJDBCVersion\""
+  println "ENV MARIADB_JDBC_SHA256=\"$mariadbJDBCSha256\""
   println "ENV MARIADB_JDBC_PREFIX=\"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/\${MARIADB_JDBC_VERSION}\""
   println "ENV MARIADB_JDBC_ARTIFACT=\"mariadb-java-client-\${MARIADB_JDBC_VERSION}.jar\""
   println "ENV MARIADB_JDBC_TARGET=\"/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/\${MARIADB_JDBC_ARTIFACT}\""