From 6f2bde0d6543bcda13dc9fb32aa81ea1a5b0d378 Mon Sep 17 00:00:00 2001 From: Torsten Mielke Date: Fri, 12 Jun 2026 13:33:05 +0200 Subject: [PATCH 1/2] CAMEL-23481: replace retired Apache Derby with H2 in camel-example repository Apache Derby is a retired Apache project. This commit migrates the jdbc/ and aggregate-dist/ examples to use H2 Database for long-term maintainability. Changes: - Replace Derby dependencies (derby, derbytools) with H2 in pom.xml - Update Spring embedded database configuration from DERBY to H2 - Rename create-derby.sql to create-h2.sql in jdbc/ example - Update identity column syntax from Derby's GENERATED ALWAYS AS IDENTITY to H2's simpler AUTO_INCREMENT syntax - All standard SQL (VARCHAR, TIMESTAMP, parameterized queries) works identically with no code changes required Unit tests for both demos pass. Made with help from AI tools. --- aggregate-dist/pom.xml | 6 +++--- .../java/org/apache/camel/example/Application.java | 4 ++-- jdbc/pom.xml | 12 ++++-------- .../main/resources/META-INF/spring/camel-context.xml | 4 ++-- .../resources/{create-derby.sql => create-h2.sql} | 4 ++-- 5 files changed, 13 insertions(+), 17 deletions(-) rename jdbc/src/main/resources/{create-derby.sql => create-h2.sql} (94%) diff --git a/aggregate-dist/pom.xml b/aggregate-dist/pom.xml index 8a5f56a60..750e3cd77 100644 --- a/aggregate-dist/pom.xml +++ b/aggregate-dist/pom.xml @@ -79,9 +79,9 @@ camel-sql - org.apache.derby - derby - ${derby-version} + com.h2database + h2 + ${h2-version} diff --git a/aggregate-dist/src/main/java/org/apache/camel/example/Application.java b/aggregate-dist/src/main/java/org/apache/camel/example/Application.java index d090bfefb..47d8ad401 100644 --- a/aggregate-dist/src/main/java/org/apache/camel/example/Application.java +++ b/aggregate-dist/src/main/java/org/apache/camel/example/Application.java @@ -56,7 +56,7 @@ public final class Application { private static final int END = 100; private static final String CID_HEADER = "corrId"; - private static final String DB_URL = "jdbc:derby:target/testdb;create=true"; + private static final String DB_URL = "jdbc:h2:file:./target/testdb"; private static final String DB_USER = "admin"; private static final String DB_PASS = "admin"; @@ -153,7 +153,7 @@ private static AggregationRepository getAggregationRepository() { + "version bigint not null" + ")"); } catch (SQLException e) { - if (!e.getMessage().contains("already exists")) { + if (!e.getMessage().toLowerCase().contains("already exist")) { LOG.error("Database initialization failure", e); } } diff --git a/jdbc/pom.xml b/jdbc/pom.xml index c127de4a9..41ff4a440 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -35,6 +35,7 @@ Database JDBC + 2.2.224 @@ -77,14 +78,9 @@ - org.apache.derby - derbytools - ${derby-version} - - - org.apache.derby - derby - ${derby-version} + com.h2database + h2 + ${h2-version} diff --git a/jdbc/src/main/resources/META-INF/spring/camel-context.xml b/jdbc/src/main/resources/META-INF/spring/camel-context.xml index 35a537b8b..15c740cd8 100644 --- a/jdbc/src/main/resources/META-INF/spring/camel-context.xml +++ b/jdbc/src/main/resources/META-INF/spring/camel-context.xml @@ -29,8 +29,8 @@ - - + +