diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java index cc49388b5b..4213e39c50 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/SqlDialectLookup.java @@ -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; }