Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a36bb1ece | ||
|
|
97b1ddca1a | ||
|
|
4697c16d14 | ||
|
|
57d5f341fd | ||
|
|
1229e8dac2 |
@@ -0,0 +1,91 @@
|
|||||||
|
# jdbc-hospital-example
|
||||||
|
|
||||||
|
This project is a example of using jdbc
|
||||||
|
|
||||||
|
The project uses the [Spock Framework Example Project](https://github.com/spockframework/)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- JDK 17 or higher
|
||||||
|
|
||||||
|
- Maven use `mvnw` wrapper
|
||||||
|
|
||||||
|
- Gradle use `gradlew` wrapper
|
||||||
|
|
||||||
|
## Building with Gradle
|
||||||
|
|
||||||
|
Downloaded files (including the Gradle distribution itself) will be stored in the Gradle user home directory (typically **user_home**`/.gradle`).
|
||||||
|
|
||||||
|
Type: test
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./gradlew clean test
|
||||||
|
```
|
||||||
|
|
||||||
|
Type: build
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./gradlew clean build
|
||||||
|
```
|
||||||
|
|
||||||
|
Type: preparation
|
||||||
|
- create a folder, for example, `project`.
|
||||||
|
- copy config/db to the folder.
|
||||||
|
- copy `jdbc_hospital_example-1.0.2.jar` from a release to the folder.
|
||||||
|
- if you build the application from source, find the file (`jdbc_hospital_example-1.0.2-all.jar`) in `build/libs/`.
|
||||||
|
- copy docker/docker-compose.yml to the folder.
|
||||||
|
- turn up the database in the `project/docker`:
|
||||||
|
```
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
- wait a minute while the database is bootstrapping.
|
||||||
|
- now you can connect with the application.
|
||||||
|
|
||||||
|
Type: run
|
||||||
|
|
||||||
|
After the preparation, run the application in the folder, for example, `project`:
|
||||||
|
```shell
|
||||||
|
java -jar jdbc_hospital_example-1.0.2.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building with Maven
|
||||||
|
|
||||||
|
Downloaded files will be stored in the local Maven repository (typically **user_home**`/.m2/repository`).
|
||||||
|
|
||||||
|
Type: test
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./mvnw clean test
|
||||||
|
```
|
||||||
|
|
||||||
|
Type: build
|
||||||
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./mvnw clean package
|
||||||
|
```
|
||||||
|
|
||||||
|
Type: preparation
|
||||||
|
- create a folder, for example, `project`.
|
||||||
|
- copy config/db to the folder.
|
||||||
|
- copy `jdbc_hospital_example-version.jar` from a release to the folder.
|
||||||
|
- if you build the application from source, find the file in `target/`.
|
||||||
|
- copy docker/docker-compose.yml to the folder.
|
||||||
|
- turn up the database in the `project/docker`:
|
||||||
|
```
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
- wait a minute while the database is bootstrapping.
|
||||||
|
- now you can connect with the application.
|
||||||
|
|
||||||
|
Type: run
|
||||||
|
|
||||||
|
After the preparation, run the application in the folder, for example, `project`:
|
||||||
|
```shell
|
||||||
|
java -jar jdbc_hospital_example-1.0.2.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
Kostiantyn Klochko (c) 2023
|
||||||
|
|
||||||
+2
-2
@@ -4,7 +4,7 @@ plugins {
|
|||||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.0.2"
|
||||||
description = "Example of using jdbc for a hostpital."
|
description = "Example of using jdbc for a hostpital."
|
||||||
|
|
||||||
application {
|
application {
|
||||||
@@ -56,7 +56,7 @@ dependencies {
|
|||||||
testRuntimeOnly 'net.bytebuddy:byte-buddy:1.14.8' // allows mocking of classes (in addition to interfaces)
|
testRuntimeOnly 'net.bytebuddy:byte-buddy:1.14.8' // allows mocking of classes (in addition to interfaces)
|
||||||
testRuntimeOnly "org.objenesis:objenesis:3.3" // allows mocking of classes without default constructor (together with ByteBuddy or CGLIB)
|
testRuntimeOnly "org.objenesis:objenesis:3.3" // allows mocking of classes without default constructor (together with ByteBuddy or CGLIB)
|
||||||
|
|
||||||
// dependencies used by examples in this project
|
// testing dependencies for sql
|
||||||
implementation "org.apache.groovy:groovy-sql"
|
implementation "org.apache.groovy:groovy-sql"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
JDBC_URL="jdbc:postgresql://localhost:5432/testdb"
|
||||||
|
JDBC_USER=user
|
||||||
|
JDBC_PASSWORD=testpassword
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: testdb
|
||||||
|
POSTGRES_USER: user
|
||||||
|
POSTGRES_PASSWORD: testpassword
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
@@ -2,20 +2,48 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.spockframework</groupId>
|
<groupId>space.kklochko</groupId>
|
||||||
<artifactId>spock-example</artifactId>
|
<artifactId>jdbc_hospital_example</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Spock Framework - Example Project</name>
|
<name>Example of using jdbc for a hostpital.</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<groovy.version>4.0.15</groovy.version>
|
<groovy.version>4.0.15</groovy.version>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.2.2</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>space.kklochko.jdbc_hospital_example.Main</mainClass>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<!-- Mandatory plugins for using Spock -->
|
<!-- Mandatory plugins for using Spock -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,
|
<!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,
|
||||||
@@ -135,27 +163,4 @@
|
|||||||
<version>${groovy.version}</version>
|
<version>${groovy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<!-- Only required if a snapshot version of Spock is used -->
|
|
||||||
<repository>
|
|
||||||
<id>spock-snapshots</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<!-- Only required in spock-example build -->
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>foo</id>
|
|
||||||
<url>file:///fake.repository.to.make.maven.happy</url>
|
|
||||||
</repository>
|
|
||||||
<snapshotRepository>
|
|
||||||
<id>bar</id>
|
|
||||||
<url>file:///fake.repository.to.make.maven.happy</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
</distributionManagement>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user