Polish "Reuse JOOQ helper to determine the dialect to use"

See gh-36991
pull/37013/head
Stephane Nicoll 1 year ago
parent 36b5500ad0
commit 37467c79d0

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 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,7 +16,9 @@
package org.springframework.boot.autoconfigure.jooq;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@ -44,14 +46,12 @@ final class SqlDialectLookup {
* @return the most suitable {@link SQLDialect}
*/
static SQLDialect getDialect(DataSource dataSource) {
if (dataSource == null) {
return SQLDialect.DEFAULT;
}
try {
return JDBCUtils.dialect(dataSource.getConnection());
Connection connection = (dataSource != null) ? dataSource.getConnection() : null;
return JDBCUtils.dialect(connection);
}
catch (SQLException ex) {
logger.warn("Unable to determine jdbc url from datasource", ex);
logger.warn("Unable to determine dialect from datasource", ex);
}
return SQLDialect.DEFAULT;
}

Loading…
Cancel
Save