Deprecate Derby support since Apache Derby is retired

Closes gh-48567
This commit is contained in:
Stéphane Nicoll
2025-12-30 17:36:53 +01:00
parent 4d402513d7
commit 12652a313e
8 changed files with 31 additions and 5 deletions
@@ -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`.
@@ -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`:
@@ -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()) {
@@ -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",
@@ -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"),
@@ -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) {
@@ -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);
}
}
@@ -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 },