From 2bf413c9a94b9582bdf9d0f56e32e2e571192cc2 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Thu, 9 Jan 2025 14:51:02 +0100 Subject: [PATCH 1/2] Add support for AWS Advanced JDBC Wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds an entry for the AWS Advanced JDBC Wrapper to the DatabaseDriver enum. This allows the driver class name to be auto-detected from jdbc:aws-wrapper:… URLs. See gh-43812 Signed-off-by: Vedran Pavic --- ...chDataSourceScriptDatabaseInitializerTests.java | 6 +++--- .../spring-boot-parent/build.gradle | 7 +++++++ spring-boot-project/spring-boot/build.gradle | 3 +++ .../springframework/boot/jdbc/DatabaseDriver.java | 14 ++++++++++++++ .../boot/jdbc/DatabaseDriverTests.java | 2 ++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java index 724fda601a6..8fd49b52cc9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceScriptDatabaseInitializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -62,8 +62,8 @@ class BatchDataSourceScriptDatabaseInitializerTests { } @ParameterizedTest - @EnumSource(value = DatabaseDriver.class, mode = Mode.EXCLUDE, names = { "CLICKHOUSE", "FIREBIRD", "INFORMIX", - "JTDS", "PHOENIX", "REDSHIFT", "TERADATA", "TESTCONTAINERS", "UNKNOWN" }) + @EnumSource(value = DatabaseDriver.class, mode = Mode.EXCLUDE, names = { "AWS_JDBC_WRAPPER", "CLICKHOUSE", + "FIREBIRD", "INFORMIX", "JTDS", "PHOENIX", "REDSHIFT", "TERADATA", "TESTCONTAINERS", "UNKNOWN" }) void batchSchemaCanBeLocated(DatabaseDriver driver) throws SQLException { DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); BatchProperties properties = new BatchProperties(); diff --git a/spring-boot-project/spring-boot-parent/build.gradle b/spring-boot-project/spring-boot-parent/build.gradle index 57b2696f2bf..c413833df81 100644 --- a/spring-boot-project/spring-boot-parent/build.gradle +++ b/spring-boot-project/spring-boot-parent/build.gradle @@ -25,6 +25,13 @@ bom { ] } } + library("AWS Advanced JDBC Wrapper", "2.5.4") { + group("software.amazon.jdbc") { + modules = [ + "aws-advanced-jdbc-wrapper" + ] + } + } library("C3P0", "0.9.5.5") { group("com.mchange") { modules = [ diff --git a/spring-boot-project/spring-boot/build.gradle b/spring-boot-project/spring-boot/build.gradle index 732a56e5921..8a3c4e32743 100644 --- a/spring-boot-project/spring-boot/build.gradle +++ b/spring-boot-project/spring-boot/build.gradle @@ -100,6 +100,9 @@ dependencies { optional("org.yaml:snakeyaml") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") + optional("software.amazon.jdbc:aws-advanced-jdbc-wrapper") { + exclude(group: "commons-logging", module: "commons-logging") + } testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) testImplementation("org.springframework:spring-core-test") diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java index 41e48fbfeb4..1f40cb74d3b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java @@ -19,6 +19,7 @@ package org.springframework.boot.jdbc; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Locale; import org.springframework.util.Assert; @@ -218,6 +219,19 @@ public enum DatabaseDriver { return Arrays.asList("ch", "clickhouse"); } + }, + + /** + * AWS Advanced JDBC Wrapper. + * @since 3.5.0 + */ + AWS_JDBC_WRAPPER(null, "software.amazon.jdbc.Driver") { + + @Override + protected Collection getUrlPrefixes() { + return List.of("aws-wrapper"); + } + }; private final String productName; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java index caeccb89041..016dd6a23ab 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java @@ -121,6 +121,8 @@ class DatabaseDriverTests { assertThat(DatabaseDriver.fromJdbcUrl("jdbc:clickhouse://localhost:3306/sample")) .isEqualTo(DatabaseDriver.CLICKHOUSE); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:ch://localhost:3306/sample")).isEqualTo(DatabaseDriver.CLICKHOUSE); + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:aws-wrapper:postgresql://127.0.0.1:5432/sample")) + .isEqualTo(DatabaseDriver.AWS_JDBC_WRAPPER); } } From d90e622d1c80dd1c631df9885bd9af03d9a9fa2e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 15 Jan 2025 18:50:10 +0000 Subject: [PATCH 2/2] Polish "Add support for AWS Advanced JDBC Wrapper" See gh-43812 --- spring-boot-project/spring-boot-parent/build.gradle | 2 +- .../java/org/springframework/boot/jdbc/DatabaseDriver.java | 5 ++--- .../org/springframework/boot/jdbc/DatabaseDriverTests.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-parent/build.gradle b/spring-boot-project/spring-boot-parent/build.gradle index c413833df81..a216a482975 100644 --- a/spring-boot-project/spring-boot-parent/build.gradle +++ b/spring-boot-project/spring-boot-parent/build.gradle @@ -28,7 +28,7 @@ bom { library("AWS Advanced JDBC Wrapper", "2.5.4") { group("software.amazon.jdbc") { modules = [ - "aws-advanced-jdbc-wrapper" + "aws-advanced-jdbc-wrapper" ] } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java index 1f40cb74d3b..19d5307eb9a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java @@ -19,7 +19,6 @@ package org.springframework.boot.jdbc; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Locale; import org.springframework.util.Assert; @@ -225,11 +224,11 @@ public enum DatabaseDriver { * AWS Advanced JDBC Wrapper. * @since 3.5.0 */ - AWS_JDBC_WRAPPER(null, "software.amazon.jdbc.Driver") { + AWS_WRAPPER(null, "software.amazon.jdbc.Driver") { @Override protected Collection getUrlPrefixes() { - return List.of("aws-wrapper"); + return Collections.singleton("aws-wrapper"); } }; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java index 016dd6a23ab..551bb5c1bd2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java @@ -122,7 +122,7 @@ class DatabaseDriverTests { .isEqualTo(DatabaseDriver.CLICKHOUSE); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:ch://localhost:3306/sample")).isEqualTo(DatabaseDriver.CLICKHOUSE); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:aws-wrapper:postgresql://127.0.0.1:5432/sample")) - .isEqualTo(DatabaseDriver.AWS_JDBC_WRAPPER); + .isEqualTo(DatabaseDriver.AWS_WRAPPER); } }