You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/06/28 06:16:47 UTC
(camel) branch main updated: chore: camel-jbang - make sql example built-in
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 6ab8d8941e2e chore: camel-jbang - make sql example built-in
6ab8d8941e2e is described below
commit 6ab8d8941e2ea448e3fd146e4049a0e66f25276e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jun 27 20:44:33 2026 +0200
chore: camel-jbang - make sql example built-in
Co-Authored-By: Claude Opus 4.7 <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
dsl/camel-jbang/camel-jbang-core/pom.xml | 4 ++
.../examples/camel-jbang-example-catalog.json | 3 +-
.../src/main/resources/examples/sql/README.md | 71 ++++++++++++++++++++++
.../resources/examples/sql/application.properties | 4 ++
.../src/main/resources/examples/sql/sql.camel.yaml | 41 +++++++++++++
5 files changed, 121 insertions(+), 2 deletions(-)
diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml b/dsl/camel-jbang/camel-jbang-core/pom.xml
index b6fc08ddf075..4f7849133372 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -322,6 +322,10 @@
<sync-example name="routes" file="application.properties"/>
<sync-example name="routes" file="beans.yaml"/>
<sync-example name="routes" file="routes.camel.yaml"/>
+ <!-- sql -->
+ <sync-example name="sql" file="README.md"/>
+ <sync-example name="sql" file="application.properties"/>
+ <sync-example name="sql" file="sql.camel.yaml"/>
<!-- timer-log -->
<sync-example name="timer-log" file="README.md"/>
<sync-example name="timer-log" file="application.properties"/>
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
index e8c46e9d8e97..91941c4cdfa8 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
@@ -498,13 +498,12 @@
"sql",
"postgres"
],
- "bundled": false,
+ "bundled": true,
"requiresDocker": true,
"hasCitrusTests": false,
"files": [
"README.md",
"application.properties",
- "compose.yaml",
"sql.camel.yaml"
],
"infraServices": [
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/README.md b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/README.md
new file mode 100644
index 000000000000..25d3afc86def
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/README.md
@@ -0,0 +1,71 @@
+## SQL
+
+This example shows how to use a SQL database with Camel.
+
+The example comes with a `docker compose` file for running a local Postgres database.
+There is also a `application.properties` configuration file that setup
+a JDBC `DataSource` for connecting to the database.
+
+### Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+```sh
+$ jbang --version
+```
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+```sh
+$ jbang app install camel@apache/camel
+```
+
+Which allows to run Camel CLI with `camel` as shown below.
+
+### How to run
+
+You can run PostgreSQL using
+
+```sh
+$ camel infra run postgres
+```
+
+Alternatively, you can run it with Docker Compose:
+
+```sh
+$ docker compose up
+```
+
+or manually with just Docker
+
+```sh
+$ docker run \
+--env POSTGRES_DB=test \
+--env POSTGRES_USER=postgres \
+--env POSTGRES_PASSWORD=postgres \
+--publish 5432:5432 \
+postgres
+```
+
+After Docker starts and pulls down the Postgres image, you can run this example using:
+
+```sh
+$ camel run *
+```
+
+This runs several routes. The first one sets up a new table called _users_, the second one fills
+it with data and the third one runs a query on that table and logs the results.
+
+### Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+[let us know](https://camel.apache.org/community/support/).
+
+We also love contributors, so
+[get involved](https://camel.apache.org/community/contributing/) :-)
+
+The Camel riders!
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/application.properties b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/application.properties
new file mode 100644
index 000000000000..2b4a090d93fa
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/application.properties
@@ -0,0 +1,4 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/test
+spring.datasource.username=test
+spring.datasource.password=test
+spring.datasource.driverClassName=org.postgresql.Driver
\ No newline at end of file
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/sql.camel.yaml b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/sql.camel.yaml
new file mode 100644
index 000000000000..e7a18a2ab2bf
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/sql/sql.camel.yaml
@@ -0,0 +1,41 @@
+- route:
+ from:
+ uri: timer
+ parameters:
+ timerName: create
+ repeatCount: 1
+ delay: 500
+ steps:
+ - to:
+ uri: sql
+ parameters:
+ query: "CREATE TABLE IF NOT EXISTS users(id integer PRIMARY KEY, name\
+ \ varchar(20), byear integer);"
+- route:
+ from:
+ uri: timer
+ parameters:
+ timerName: insert
+ repeatCount: 1
+ delay: 1000
+ steps:
+ - to:
+ uri: sql
+ parameters:
+ query: "INSERT INTO users(id, name, byear) VALUES(1, 'Camel', 2025)\
+ \ ON CONFLICT DO NOTHING;"
+- route:
+ from:
+ uri: timer
+ parameters:
+ timerName: select
+ repeatCount: 1
+ delay: 2000
+ steps:
+ - to:
+ uri: sql
+ parameters:
+ query: SELECT * FROM users
+ - log:
+ message: "${body}"
+