You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ap...@apache.org on 2026/06/12 13:38:40 UTC
(camel-examples) 01/02: CAMEL-23481: replace retired Apache Derby with H2 in camel-example repository
This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-examples.git
commit 760341c79eb8a0ccc881ad3d53a5518622d12b18
Author: Torsten Mielke <tm...@ibm.com>
AuthorDate: Fri Jun 12 13:33:05 2026 +0200
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 +++---
.../src/main/java/org/apache/camel/example/Application.java | 4 ++--
jdbc/pom.xml | 12 ++++--------
jdbc/src/main/resources/META-INF/spring/camel-context.xml | 4 ++--
jdbc/src/main/resources/{create-derby.sql => create-h2.sql} | 4 ++--
5 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/aggregate-dist/pom.xml b/aggregate-dist/pom.xml
index 8a5f56a6..750e3cd7 100644
--- a/aggregate-dist/pom.xml
+++ b/aggregate-dist/pom.xml
@@ -79,9 +79,9 @@
<artifactId>camel-sql</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${derby-version}</version>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2-version}</version>
</dependency>
<!-- logging -->
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 d090bfef..47d8ad40 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 @@ public final class Application {
+ "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 c127de4a..41ff4a44 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -35,6 +35,7 @@
<properties>
<category>Database</category>
<title>JDBC</title>
+ <h2-version>2.2.224</h2-version>
</properties>
<dependencyManagement>
@@ -77,14 +78,9 @@
<!-- jdbc -->
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbytools</artifactId>
- <version>${derby-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${derby-version}</version>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2-version}</version>
</dependency>
<!-- logging -->
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 35a537b8..15c740cd 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 @@
<!--
Embedded in-memory database setup.
-->
- <jdbc:embedded-database id="dataSource" type="DERBY">
- <jdbc:script location="classpath:create-derby.sql"/>
+ <jdbc:embedded-database id="dataSource" type="H2">
+ <jdbc:script location="classpath:create-h2.sql"/>
</jdbc:embedded-database>
<!--
diff --git a/jdbc/src/main/resources/create-derby.sql b/jdbc/src/main/resources/create-h2.sql
similarity index 94%
rename from jdbc/src/main/resources/create-derby.sql
rename to jdbc/src/main/resources/create-h2.sql
index 4f00aefc..930bf497 100644
--- a/jdbc/src/main/resources/create-derby.sql
+++ b/jdbc/src/main/resources/create-h2.sql
@@ -34,8 +34,8 @@
/*
STATUS : 'NEW', 'DONE'
*/
-CREATE TABLE CAMEL_TEST (
- ID BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
+CREATE TABLE CAMEL_TEST (
+ ID BIGINT AUTO_INCREMENT,
MSG VARCHAR(10240),
STATUS CHAR(4) DEFAULT 'NEW',
CREATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP