Fixes #3428 external database

This commit is contained in:
Ludy87 2025-04-29 18:18:15 +02:00
parent 35ecff053a
commit 80d2d5e3a3
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -240,8 +240,32 @@ public class DatabaseService implements DatabaseInterface {
private boolean isH2Database() {
ApplicationProperties.Datasource datasource =
applicationProperties.getSystem().getDatasource();
return !datasource.isEnableCustomDatabase()
|| datasource.getType().equalsIgnoreCase(ApplicationProperties.Driver.H2.name());
boolean isTypeH2 =
datasource.getType().equalsIgnoreCase(ApplicationProperties.Driver.H2.name());
boolean isDBUrlH2 =
datasource.getCustomDatabaseUrl().contains("h2")
|| datasource.getCustomDatabaseUrl().contains("H2");
if (isTypeH2 && !isDBUrlH2) {
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) {
log.warn(
"Datasource URL contains 'h2', but the type is not H2. "
+ "Please check your configuration.");
throw new IllegalStateException(
"Datasource URL contains 'h2', but the type is not H2. Please check your"
+ " configuration.");
}
boolean isH2 = isTypeH2 && isDBUrlH2;
return !datasource.isEnableCustomDatabase() || isH2;
}
/**