From 12652a313e1aa155d978a6c540c9517c24a3fddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 30 Dec 2025 17:33:03 +0100 Subject: [PATCH] Deprecate Derby support since Apache Derby is retired Closes gh-48567 --- .../how-to/pages/data-initialization.adoc | 2 +- .../antora/modules/reference/pages/data/sql.adoc | 4 ++-- .../DevToolsDataSourceAutoConfiguration.java | 4 ++++ ...lsPooledDataSourceAutoConfigurationTests.java | 2 ++ .../boot/jdbc/DatabaseDriver.java | 2 ++ .../boot/jdbc/EmbeddedDatabaseConnection.java | 3 +++ .../boot/jdbc/DatabaseDriverTests.java | 16 ++++++++++++++-- .../jdbc/EmbeddedDatabaseConnectionTests.java | 3 +++ 8 files changed, 31 insertions(+), 5 deletions(-) diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-initialization.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-initialization.adoc index 42050f05a7c..c3fbe3ae706 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-initialization.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-initialization.adoc @@ -14,7 +14,7 @@ You can set configprop:spring.jpa.hibernate.ddl-auto[] to control Hibernate's da Supported values are `none`, `validate`, `update`, `create`, and `create-drop`. Spring Boot chooses a default value for you based on whether you are using an embedded database. An embedded database is identified by looking at the javadoc:java.sql.Connection[] type and JDBC url. -`hsqldb`, `h2`, or `derby` are embedded databases and others are not. +`hsqldb`, `h2`, or `derby` (deprecated) are embedded databases and others are not. If an embedded database is identified and no schema manager (Flyway or Liquibase) has been detected, `ddl-auto` defaults to `create-drop`. In all other cases, it defaults to `none`. diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc index accaec7f94b..33b0ee27165 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc @@ -25,7 +25,7 @@ You need to populate your database when your application starts and be prepared TIP: The "`How-to Guides`" section includes a xref:how-to:data-initialization.adoc[section on how to initialize a database]. -Spring Boot can auto-configure embedded https://www.h2database.com[H2], https://hsqldb.org/[HSQL], and https://db.apache.org/derby/[Derby] databases. +Spring Boot can auto-configure embedded https://www.h2database.com[H2], https://hsqldb.org/[HSQL], and https://db.apache.org/derby/[Derby] (deprecated) databases. You need not provide any connection URLs. You need only include a build dependency to the embedded database that you want to use. If there are multiple embedded databases on the classpath, set the configprop:spring.datasource.embedded-database-connection[] configuration property to control which one is used. @@ -283,7 +283,7 @@ NOTE: For more details, check the {url-spring-data-jpa-docs}/envers.html[Spring [[data.sql.jpa-and-spring-data.creating-and-dropping]] === Creating and Dropping JPA Databases -By default, JPA databases are automatically created *only* if you use an embedded database (H2, HSQL, or Derby). +By default, JPA databases are automatically created *only* if you use an embedded database, that is H2, HSQL, or Derby (deprecated). You can explicitly configure JPA settings by using `+spring.jpa.*+` properties. For example, to create and drop tables you can add the following line to your `application.properties`: diff --git a/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java b/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java index fbf29e60864..3326fc7541a 100644 --- a/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java +++ b/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java @@ -119,6 +119,10 @@ public final class DevToolsDataSourceAutoConfiguration { private enum InMemoryDatabase { + /* + * @deprecated since 4.1.0 for removal in 4.3.0 as Derby is EOL. + */ + @Deprecated(since = "4.1.0", forRemoval = true) DERBY(null, Set.of("org.apache.derby.jdbc.EmbeddedDriver"), (dataSource) -> { String url; try (Connection connection = dataSource.getConnection()) { diff --git a/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java b/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java index f61d0eb6831..cc9826b49ae 100644 --- a/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java +++ b/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java @@ -120,6 +120,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat } @Test + @Deprecated(since = "4.1.0", forRemoval = true) void derbyClientIsNotShutdown() throws Exception { try (ConfigurableApplicationContext context = getContext( () -> createContext("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost", @@ -131,6 +132,7 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat } @Test + @Deprecated(since = "4.1.0", forRemoval = true) void inMemoryDerbyIsShutdown() throws Exception { try (ConfigurableApplicationContext context = getContext( () -> createContext("org.apache.derby.jdbc.EmbeddedDriver", "jdbc:derby:memory:test;create=true", diff --git a/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java b/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java index 0fbaeaa2cfc..d7c589209b5 100644 --- a/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java +++ b/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java @@ -44,7 +44,9 @@ public enum DatabaseDriver { /** * Apache Derby. + * @deprecated since 4.1.0 for removal in 4.3.0 as Derby is EOL. */ + @Deprecated(since = "4.1.0", forRemoval = true) DERBY("Apache Derby", "org.apache.derby.jdbc.EmbeddedDriver", "org.apache.derby.jdbc.EmbeddedXADataSource", "SELECT 1 FROM SYSIBM.SYSDUMMY1"), diff --git a/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java b/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java index b5809c6c023..b413df5fdac 100644 --- a/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java +++ b/module/spring-boot-jdbc/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java @@ -57,7 +57,9 @@ public enum EmbeddedDatabaseConnection { /** * Derby Database Connection. + * @deprecated since 4.1.0 for removal in 4.3.0 as Derby is EOL. */ + @Deprecated(since = "4.1.0", forRemoval = true) DERBY("jdbc:derby:memory:%s;create=true"), /** @@ -83,6 +85,7 @@ public enum EmbeddedDatabaseConnection { * Returns the driver class name. * @return the driver class name */ + @SuppressWarnings("removal") public @Nullable String getDriverClassName() { // See https://github.com/spring-projects/spring-boot/issues/32865 return switch (this) { diff --git a/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java b/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java index 479098dfe98..7ecb8727a87 100644 --- a/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java +++ b/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java @@ -63,7 +63,6 @@ class DatabaseDriverTests { @Test void databaseProductNameLookups() { assertThat(DatabaseDriver.fromProductName("newone")).isEqualTo(DatabaseDriver.UNKNOWN); - assertThat(DatabaseDriver.fromProductName("Apache Derby")).isEqualTo(DatabaseDriver.DERBY); assertThat(DatabaseDriver.fromProductName("H2")).isEqualTo(DatabaseDriver.H2); assertThat(DatabaseDriver.fromProductName("HDB")).isEqualTo(DatabaseDriver.HANA); assertThat(DatabaseDriver.fromProductName("HSQL Database Engine")).isEqualTo(DatabaseDriver.HSQLDB); @@ -87,10 +86,16 @@ class DatabaseDriverTests { assertThat(DatabaseDriver.fromProductName("ClickHouse")).isEqualTo(DatabaseDriver.CLICKHOUSE); } + @Test + @Deprecated(since = "4.1.0", forRemoval = true) + @SuppressWarnings("removal") + void deprecatedDatabaseProductNameLookups() { + assertThat(DatabaseDriver.fromProductName("Apache Derby")).isEqualTo(DatabaseDriver.DERBY); + } + @Test void databaseJdbcUrlLookups() { assertThat(DatabaseDriver.fromJdbcUrl("jdbc:newone://localhost")).isEqualTo(DatabaseDriver.UNKNOWN); - assertThat(DatabaseDriver.fromJdbcUrl("jdbc:derby:sample")).isEqualTo(DatabaseDriver.DERBY); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:h2:~/sample")).isEqualTo(DatabaseDriver.H2); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:hsqldb:hsql://localhost")).isEqualTo(DatabaseDriver.HSQLDB); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:sqlite:sample.db")).isEqualTo(DatabaseDriver.SQLITE); @@ -125,4 +130,11 @@ class DatabaseDriverTests { .isEqualTo(DatabaseDriver.AWS_WRAPPER); } + @Test + @Deprecated(since = "4.1.0", forRemoval = true) + @SuppressWarnings("removal") + void deprecatedDatabaseJdbcUrlLookups() { + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:derby:sample")).isEqualTo(DatabaseDriver.DERBY); + } + } diff --git a/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnectionTests.java b/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnectionTests.java index 5e33d9d0331..2d51114a425 100644 --- a/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnectionTests.java +++ b/module/spring-boot-jdbc/src/test/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnectionTests.java @@ -51,6 +51,8 @@ class EmbeddedDatabaseConnectionTests { } @Test + @Deprecated(since = "4.1.0", forRemoval = true) + @SuppressWarnings("removal") void derbyCustomDatabaseName() { assertThat(EmbeddedDatabaseConnection.DERBY.getUrl("myderbydb")) .isEqualTo("jdbc:derby:memory:myderbydb;create=true"); @@ -80,6 +82,7 @@ class EmbeddedDatabaseConnectionTests { assertThat(EmbeddedDatabaseConnection.isEmbedded(driverClassName, url)).isEqualTo(embedded); } + @SuppressWarnings("removal") static Object[] embeddedDriverAndUrlParameters() { return new Object[] { new Object[] { EmbeddedDatabaseConnection.H2.getDriverClassName(), "jdbc:h2:~/test", false },