diff --git a/roles/keycloak/templates/standalone-ha.xml.j2 b/roles/keycloak/templates/standalone-ha.xml.j2
index 67f5da8..e3b62ea 100644
--- a/roles/keycloak/templates/standalone-ha.xml.j2
+++ b/roles/keycloak/templates/standalone-ha.xml.j2
@@ -139,8 +139,10 @@
{{ keycloak_jdbc[keycloak_jdbc_engine].validate_query }}
{{ keycloak_db_background_validate_on_match }}
+{% if keycloak_db_background_validation_millis > 0 or keycloak_db_background_validation %}
{{ keycloak_db_background_validation }}
{{ keycloak_db_background_validation_millis }}
+{% endif %}
{% else %}
jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE
diff --git a/roles/keycloak/templates/standalone-infinispan.xml.j2 b/roles/keycloak/templates/standalone-infinispan.xml.j2
index cea9c87..c1590cd 100644
--- a/roles/keycloak/templates/standalone-infinispan.xml.j2
+++ b/roles/keycloak/templates/standalone-infinispan.xml.j2
@@ -139,8 +139,10 @@
{{ keycloak_jdbc[keycloak_jdbc_engine].validate_query }}
{{ keycloak_db_background_validate_on_match }}
+{% if keycloak_db_background_validation_millis > 0 or keycloak_db_background_validation %}
{{ keycloak_db_background_validation }}
{{ keycloak_db_background_validation_millis }}
+{% endif %}
{% else %}
jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE
diff --git a/roles/keycloak/templates/standalone.xml.j2 b/roles/keycloak/templates/standalone.xml.j2
index e38e1f0..4e5aa05 100644
--- a/roles/keycloak/templates/standalone.xml.j2
+++ b/roles/keycloak/templates/standalone.xml.j2
@@ -126,8 +126,10 @@
{{ keycloak_jdbc[keycloak_jdbc_engine].validate_query }}
{{ keycloak_db_background_validate_on_match }}
+{% if keycloak_db_background_validation_millis > 0 or keycloak_db_background_validation %}
{{ keycloak_db_background_validation }}
{{ keycloak_db_background_validation_millis }}
+{% endif %}
{% else %}
jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE