Update DatabaseService.java

This commit is contained in:
Ludy 2025-05-02 00:15:47 +02:00 committed by GitHub
parent d95f169ebd
commit 7fae826f9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -246,15 +246,16 @@ public class DatabaseService implements DatabaseInterface {
boolean isDBUrlH2 =
datasource.getCustomDatabaseUrl().contains("h2")
|| datasource.getCustomDatabaseUrl().contains("H2");
boolean isCustomDatabase = datasource.isEnableCustomDatabase();
if (isTypeH2 && !isDBUrlH2) {
if (isTypeH2 && !isDBUrlH2 && isCustomDatabase) {
log.warn(
"Datasource type is H2, but the URL does not contain 'h2'. "
+ "Please check your configuration.");
throw new IllegalStateException(
"Datasource type is H2, but the URL does not contain 'h2'. Please check your"
+ " configuration.");
} else if (!isTypeH2 && isDBUrlH2) {
} else if (!isTypeH2 && isDBUrlH2 && isCustomDatabase) {
log.warn(
"Datasource URL contains 'h2', but the type is not H2. "
+ "Please check your configuration.");
@ -265,7 +266,7 @@ public class DatabaseService implements DatabaseInterface {
boolean isH2 = isTypeH2 && isDBUrlH2;
return !datasource.isEnableCustomDatabase() || isH2;
return !isCustomDatabase || isH2;
}
/**