Skip to content

Commit fbfe2fb

Browse files
Replace employee-app with dbclient/oracle-ucp (#204)
1 parent 5ce8cae commit fbfe2fb

File tree

29 files changed

+619
-2431
lines changed

29 files changed

+619
-2431
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Helidon Examples DbClient Oracle UCP
2+
3+
This project implements a simple CRUD service using Helidon SE and Helidon DbClient.
4+
5+
## Build
6+
7+
```shell
8+
mvn package
9+
```
10+
11+
## Run
12+
13+
Start the database:
14+
```shell
15+
docker run -d \
16+
--name oracledb \
17+
-e ORACLE_PWD=oracle123 \
18+
-p 1521:1521 \
19+
container-registry.oracle.com/database/free:latest-lite
20+
```
21+
22+
Or, if the container already exists:
23+
```shell
24+
docker start oracledb
25+
```
26+
27+
Start the application:
28+
```shell
29+
java -jar target/helidon-examples-dbclient-oracle-ucp.jar
30+
```
31+
32+
Restart the application:
33+
```shell
34+
java -Ddb.init=false -jar target/helidon-examples-dbclient-oracle-ucp.jar
35+
```
36+
37+
### Exercise the application
38+
39+
```shell
40+
# create two pokemons
41+
curl -X POST -d '{"name": "Pikachu", "type": "Electric"}' -H "Content-Type: application/json" http://localhost:8080/pokemon
42+
curl -X POST -d '{"name": "Raticate", "type": "Normal"}' -H "Content-Type: application/json" http://localhost:8080/pokemon
43+
44+
# list all pokemons
45+
curl -X GET http://localhost:8080/pokemon
46+
47+
# update
48+
curl -X PUT -d '{"type": "Ice"}' -H "Content-Type: application/json" http://localhost:8080/pokemon/Raticate
49+
50+
# get a pokemon
51+
curl -X GET http://localhost:8080/pokemon/Raticate
52+
53+
# delete a pokemon
54+
curl -X DELETE http://localhost:8080/pokemon/Raticate
55+
56+
# delete all pokemons
57+
curl -X DELETE http://localhost:8080/pokemon
58+
59+
# verify all deleted
60+
curl -X GET http://localhost:8080/pokemon
61+
```
62+
63+
## Stop
64+
65+
```shell
66+
docker stop oracledb
67+
```
68+
69+
---
70+
71+
Pokémon, and Pokémon character names are trademarks of Nintendo.
Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
2-
1+
<?xml version="1.0" encoding="UTF-8"?>
32
<!--
4-
5-
Copyright (c) 2019, 2025 Oracle and/or its affiliates.
3+
Copyright (c) 2025 Oracle and/or its affiliates.
64
75
Licensed under the Apache License, Version 2.0 (the "License");
86
you may not use this file except in compliance with the License.
@@ -15,78 +13,85 @@
1513
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1614
See the License for the specific language governing permissions and
1715
limitations under the License.
16+
-->
1817

19-
-->
2018
<project xmlns="http://maven.apache.org/POM/4.0.0"
21-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
23-
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2421
<modelVersion>4.0.0</modelVersion>
2522
<parent>
2623
<groupId>io.helidon.applications</groupId>
2724
<artifactId>helidon-se</artifactId>
2825
<version>4.3.0-SNAPSHOT</version>
2926
<relativePath/>
3027
</parent>
31-
<groupId>io.helidon.examples.employee</groupId>
32-
<artifactId>helidon-examples-employee-app</artifactId>
28+
<artifactId>helidon-examples-dbclient-oracle-ucp</artifactId>
3329
<version>1.0.0-SNAPSHOT</version>
34-
<name>Helidon Examples Employee App</name>
30+
<name>Helidon Examples DbClient Oracle UCP</name>
3531

3632
<properties>
37-
<mainClass>io.helidon.examples.employee.Main</mainClass>
33+
<mainClass>io.helidon.examples.dbclient.oracle.ucp.Main</mainClass>
3834
</properties>
3935

4036
<dependencies>
4137
<dependency>
42-
<groupId>io.helidon.integrations.db</groupId>
43-
<artifactId>ojdbc</artifactId>
38+
<groupId>io.helidon.webserver</groupId>
39+
<artifactId>helidon-webserver</artifactId>
4440
</dependency>
4541
<dependency>
46-
<groupId>com.oracle.database.jdbc</groupId>
47-
<artifactId>ucp</artifactId>
42+
<groupId>io.helidon.http.media</groupId>
43+
<artifactId>helidon-http-media-jsonp</artifactId>
4844
</dependency>
4945
<dependency>
50-
<groupId>io.helidon.webserver</groupId>
51-
<artifactId>helidon-webserver</artifactId>
46+
<groupId>io.helidon.config</groupId>
47+
<artifactId>helidon-config-yaml</artifactId>
5248
</dependency>
5349
<dependency>
54-
<groupId>io.helidon.webserver.observe</groupId>
55-
<artifactId>helidon-webserver-observe</artifactId>
50+
<groupId>io.helidon.dbclient</groupId>
51+
<artifactId>helidon-dbclient</artifactId>
5652
</dependency>
5753
<dependency>
58-
<groupId>io.helidon.webserver</groupId>
59-
<artifactId>helidon-webserver-static-content</artifactId>
54+
<groupId>io.helidon.dbclient</groupId>
55+
<artifactId>helidon-dbclient-jdbc</artifactId>
6056
</dependency>
6157
<dependency>
62-
<groupId>io.helidon.http.media</groupId>
63-
<artifactId>helidon-http-media-jsonb</artifactId>
58+
<groupId>io.helidon.integrations.db</groupId>
59+
<artifactId>ojdbc</artifactId>
6460
</dependency>
6561
<dependency>
66-
<groupId>io.helidon.config</groupId>
67-
<artifactId>helidon-config-yaml</artifactId>
62+
<groupId>com.oracle.database.jdbc</groupId>
63+
<artifactId>ucp17</artifactId>
6864
</dependency>
6965
<dependency>
70-
<groupId>io.helidon.health</groupId>
71-
<artifactId>helidon-health-checks</artifactId>
66+
<groupId>jakarta.json</groupId>
67+
<artifactId>jakarta.json-api</artifactId>
7268
</dependency>
7369
<dependency>
74-
<groupId>io.helidon.webserver.observe</groupId>
75-
<artifactId>helidon-webserver-observe-metrics</artifactId>
76-
<scope>runtime</scope>
70+
<groupId>io.helidon.logging</groupId>
71+
<artifactId>helidon-logging-slf4j</artifactId>
7772
</dependency>
7873
<dependency>
79-
<groupId>io.helidon.metrics</groupId>
80-
<artifactId>helidon-metrics-system-meters</artifactId>
81-
<scope>runtime</scope>
74+
<groupId>org.slf4j</groupId>
75+
<artifactId>jul-to-slf4j</artifactId>
8276
</dependency>
8377
<dependency>
84-
<groupId>io.helidon.dbclient</groupId>
85-
<artifactId>helidon-dbclient</artifactId>
78+
<groupId>org.slf4j</groupId>
79+
<artifactId>slf4j-simple</artifactId>
8680
</dependency>
8781
<dependency>
88-
<groupId>io.helidon.dbclient</groupId>
89-
<artifactId>helidon-dbclient-jdbc</artifactId>
82+
<groupId>org.testcontainers</groupId>
83+
<artifactId>junit-jupiter</artifactId>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>io.helidon.webclient</groupId>
88+
<artifactId>helidon-webclient</artifactId>
89+
<scope>test</scope>
90+
</dependency>
91+
<dependency>
92+
<groupId>io.helidon.testing</groupId>
93+
<artifactId>helidon-testing-junit5</artifactId>
94+
<scope>test</scope>
9095
</dependency>
9196
<dependency>
9297
<groupId>io.helidon.webserver.testing.junit5</groupId>
@@ -118,5 +123,4 @@
118123
</plugin>
119124
</plugins>
120125
</build>
121-
122126
</project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2025 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.examples.dbclient.oracle.ucp;
18+
19+
import io.helidon.config.Config;
20+
import io.helidon.logging.common.LogConfig;
21+
import io.helidon.service.registry.Services;
22+
import io.helidon.webserver.WebServer;
23+
import io.helidon.webserver.http.HttpRouting;
24+
25+
/**
26+
* The application main class.
27+
*/
28+
public final class Main {
29+
30+
/**
31+
* Cannot be instantiated.
32+
*/
33+
private Main() {
34+
}
35+
36+
/**
37+
* Application main entry point.
38+
*
39+
* @param args command line arguments.
40+
*/
41+
public static void main(String[] args) {
42+
LogConfig.configureRuntime();
43+
44+
// initialize global config from default configuration
45+
Config config = Services.get(Config.class);
46+
47+
WebServer server = WebServer.builder()
48+
.config(config.get("server"))
49+
.routing(Main::routing)
50+
.build()
51+
.start();
52+
53+
System.out.println("WEB server is up! http://localhost:" + server.port() + "/");
54+
}
55+
56+
static void routing(HttpRouting.Builder routing) {
57+
Config config = Services.get(Config.class);
58+
routing.register("/pokemon", new PokemonService(config.get("db")));
59+
}
60+
}

0 commit comments

Comments
 (0)