Reuse JOOQ helper to determine the dialect to use
See gh-36991
This commit is contained in:
parent
a30c075e2f
commit
36b5500ad0
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.jooq;
|
package org.springframework.boot.autoconfigure.jooq;
|
||||||
|
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -25,14 +24,12 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import org.jooq.SQLDialect;
|
import org.jooq.SQLDialect;
|
||||||
import org.jooq.tools.jdbc.JDBCUtils;
|
import org.jooq.tools.jdbc.JDBCUtils;
|
||||||
|
|
||||||
import org.springframework.jdbc.support.JdbcUtils;
|
|
||||||
import org.springframework.jdbc.support.MetaDataAccessException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility to lookup well known {@link SQLDialect SQLDialects} from a {@link DataSource}.
|
* Utility to lookup well known {@link SQLDialect SQLDialects} from a {@link DataSource}.
|
||||||
*
|
*
|
||||||
* @author Michael Simons
|
* @author Michael Simons
|
||||||
* @author Lukas Eder
|
* @author Lukas Eder
|
||||||
|
* @author Ramil Saetov
|
||||||
*/
|
*/
|
||||||
final class SqlDialectLookup {
|
final class SqlDialectLookup {
|
||||||
|
|
||||||
|
@ -51,13 +48,9 @@ final class SqlDialectLookup {
|
||||||
return SQLDialect.DEFAULT;
|
return SQLDialect.DEFAULT;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String url = JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getURL);
|
return JDBCUtils.dialect(dataSource.getConnection());
|
||||||
SQLDialect sqlDialect = JDBCUtils.dialect(url);
|
|
||||||
if (sqlDialect != null) {
|
|
||||||
return sqlDialect;
|
|
||||||
}
|
}
|
||||||
}
|
catch (SQLException ex) {
|
||||||
catch (MetaDataAccessException ex) {
|
|
||||||
logger.warn("Unable to determine jdbc url from datasource", ex);
|
logger.warn("Unable to determine jdbc url from datasource", ex);
|
||||||
}
|
}
|
||||||
return SQLDialect.DEFAULT;
|
return SQLDialect.DEFAULT;
|
||||||
|
|
Loading…
Reference in New Issue