Helidon MP application that uses the dbclient API with MySQL database.
To execute this example you need to run a MySQL database with (dummy?) credentials
Database: books Username: user Password: changeit JDBC Url: jdbc:mysql://127.0.0.1:3306/books?useSSL=false
You could start this database by using Docker, please note this database will be deleted after stopping the container:
docker run --name helidon-books-db --rm -e MYSQL_RANDOM_ROOT_PASSWORD=yes \
-e MYSQL_USER=user \
-e MYSQL_PASSWORD=changeit \
-e MYSQL_DATABASE=books -p 3306:3306 mysql:8.3
With JDK21
mvn package
#Same values as the database
export JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_URL="jdbc:mysql://127.0.0.1:3306/books?useSSL=false&allowPublicKeyRetrieval=true"
export JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_USER=user
export JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_PASSWORD=changeit
java -jar target/helidon-books.jar
mvn clean verify k8s:build
docker run --name helidon-books --rm \
-e JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_URL="jdbc:mysql://host.docker.internal:3306/books?useSSL=false&allowPublicKeyRetrieval=true" \
-e JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_USER=user \
-e JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_PASSWORD=changeit \
-p 8080:8080 \
tuxtor/helidon-books:latest
mvn clean verify k8s:build
docker run --name helidon-books --rm \
-e JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_URL="jdbc:mysql://localhost:3306/books?useSSL=false&allowPublicKeyRetrieval=true" \
-e JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_USER=user \
-e JAVAX_SQL_DATASOURCE_BOOKSDS_DATASOURCE_PASSWORD=changeit \
-p 8080:8080 \
tuxtor/helidon-books:latest
If you don’t have access to a Kubernetes cluster, you can install one on your desktop and use it as the default kubernetes cluster.
Currently JKube is configured to publish the image at Dockerhub
<properties>
<jkube.generator.name>tuxtor/helidon-books:%l</jkube.generator.name>
</properties>
You could adapt this part to use another registry -e.g. AWS, Oracle Cloud, Azure-. Then you could simply execute
mvn k8s:build k8s:push
To execute the application, they you could generate the final Kubernetes descriptor and apply it
mvn k8s:resource k8s:apply