diff --git a/dataflow-website/recipes/file-ingest/file-to-jdbc/README.md b/dataflow-website/recipes/file-ingest/file-to-jdbc/README.md new file mode 100644 index 0000000..6288b33 --- /dev/null +++ b/dataflow-website/recipes/file-ingest/file-to-jdbc/README.md @@ -0,0 +1,25 @@ +File to JDBC Ingest Spring Batch Sample +--- + +This project implements a Spring Batch job that reads from a CSV text file with lines formatted as `first_name,last_name` and writes each entry to a database table using a [JdbcBatchItemWriter](https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/item/database/JdbcBatchItemWriter.html)] that executes `INSERT INTO people (first_name, last_name) VALUES (:firstName, :lastName)` for each line. + + +## Build + +### To run locally with an H2 database or with Cloud Foundry Java Buildpack to bind to a JDBC service: + +```bash +$ ./mvnw clean package +``` + +### To run in Kubernetes (and add a Mariadb driver) + +```bash +$ ./mvnw clean package docker:build -Pkubernetes +``` + +### To zip the source code and test data: + +```bash +$ ./mvnw clean package -Pdist +``` \ No newline at end of file diff --git a/dataflow-website/recipes/file-ingest/file-to-jdbc/file-to-jdbc.zip b/dataflow-website/recipes/file-ingest/file-to-jdbc/file-to-jdbc.zip new file mode 100644 index 0000000..f4595c8 Binary files /dev/null and b/dataflow-website/recipes/file-ingest/file-to-jdbc/file-to-jdbc.zip differ diff --git a/dataflow-website/recipes/file-ingest/file-to-jdbc/pom.xml b/dataflow-website/recipes/file-ingest/file-to-jdbc/pom.xml index aaacc2a..a0e7605 100644 --- a/dataflow-website/recipes/file-ingest/file-to-jdbc/pom.xml +++ b/dataflow-website/recipes/file-ingest/file-to-jdbc/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 io.spring.cloud.dataflow.ingest ingest @@ -49,21 +49,63 @@ - - kubernetes - - - com.h2database - h2 - test - - - org.mariadb.jdbc - mariadb-java-client - 2.3.0 - - - + + kubernetes + + + com.h2database + h2 + test + + + org.mariadb.jdbc + mariadb-java-client + 2.3.0 + + + + + dist + + + + maven-antrun-plugin + + + package + + + + + + + run + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + prepare-package + + single + + + false + + src/main/assembly/assembly.xml + + + + + + + + @@ -84,33 +126,33 @@ - io.fabric8 - docker-maven-plugin - 0.14.2 - - - - ${docker.org}/${project.artifactId} - - springcloud/openjdk - - /tmp - - - - java - -jar - /maven/ingest.jar - - - - assembly.xml - - - - - - + io.fabric8 + docker-maven-plugin + 0.14.2 + + + + ${docker.org}/${project.artifactId} + + springcloud/openjdk + + /tmp + + + + java + -jar + /maven/ingest.jar + + + + assembly.xml + + + + + + @@ -151,5 +193,5 @@ ${checkstyle.plugin.version} - + diff --git a/dataflow-website/recipes/file-ingest/file-to-jdbc/src/main/assembly/assembly.xml b/dataflow-website/recipes/file-ingest/file-to-jdbc/src/main/assembly/assembly.xml new file mode 100644 index 0000000..3f2aeb3 --- /dev/null +++ b/dataflow-website/recipes/file-ingest/file-to-jdbc/src/main/assembly/assembly.xml @@ -0,0 +1,23 @@ + + zip + true + + + zip + + file-to-jdbc + + + ${project.basedir} + + **/target/** + *.zip + + + + ${project.basedir}/../data + + + \ No newline at end of file