@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 2021 the original author or authors .
* Copyright 2012 - 2023 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -16,6 +16,7 @@
@@ -16,6 +16,7 @@
package org.springframework.boot.jdbc.init ;
import java.sql.DatabaseMetaData ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.LinkedHashMap ;
@ -26,6 +27,7 @@ import java.util.function.Supplier;
@@ -26,6 +27,7 @@ import java.util.function.Supplier;
import javax.sql.DataSource ;
import org.springframework.boot.jdbc.DatabaseDriver ;
import org.springframework.jdbc.support.JdbcUtils ;
import org.springframework.util.Assert ;
import org.springframework.util.ObjectUtils ;
import org.springframework.util.StringUtils ;
@ -89,7 +91,6 @@ public class PlatformPlaceholderDatabaseDriverResolver {
@@ -89,7 +91,6 @@ public class PlatformPlaceholderDatabaseDriverResolver {
* @param dataSource the DataSource from which the { @link DatabaseDriver } is derived
* @param values the values in which placeholders are resolved
* @return the values with their placeholders resolved
* @see DatabaseDriver # fromDataSource ( DataSource )
* /
public List < String > resolveAll ( DataSource dataSource , String . . . values ) {
Assert . notNull ( dataSource , "DataSource must not be null" ) ;
@ -134,7 +135,14 @@ public class PlatformPlaceholderDatabaseDriverResolver {
@@ -134,7 +135,14 @@ public class PlatformPlaceholderDatabaseDriverResolver {
}
DatabaseDriver getDatabaseDriver ( DataSource dataSource ) {
return DatabaseDriver . fromDataSource ( dataSource ) ;
try {
String productName = JdbcUtils . commonDatabaseName (
JdbcUtils . extractDatabaseMetaData ( dataSource , DatabaseMetaData : : getDatabaseProductName ) ) ;
return DatabaseDriver . fromProductName ( productName ) ;
}
catch ( Exception ex ) {
throw new IllegalStateException ( "Failed to determine DatabaseDriver" , ex ) ;
}
}
}