BAEL-1348 | BatchProcessing example using jdbc (#3216)
* BAEL-EVAL | Adding an example to demo Bean Injection ### Changes done A Spring boot app to demo bean injection * Adding @Autowired for Constructor Injection * BAEL-EVAL | Correcting the method name * BAEL-EVAL * BAEL-1348 | Adding example of Batch Processing in JDBC ### Changes done - Added one example using statement - Added one example using preparedstatement * Removing evaluation article * BAEL-1348 | Adding example of Batch Processing in JDBC ### Changes done - Added an example using statement - Added an example using preparedstatement * BAEL-1348 | BatchProcessing example using jdbc ### Changes done - Add example using statement - Add example using PreparedStatement - Add Unit Tests * BAEL-1348 | Changes to pom.xml and refactoring UnitTest * BAEL-1348 | Removing the example using spring-boot
This commit is contained in:
parent
617c2ffdba
commit
94ace2eda8
@ -1,496 +1,495 @@
|
|||||||
<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/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>core-java</artifactId>
|
<artifactId>core-java</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>core-java</name>
|
<name>core-java</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- utils -->
|
<!-- utils -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sourceforge.collections</groupId>
|
<groupId>net.sourceforge.collections</groupId>
|
||||||
<artifactId>collections-generic</artifactId>
|
<artifactId>collections-generic</artifactId>
|
||||||
<version>${collections-generic.version}</version>
|
<version>${collections-generic.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>${guava.version}</version>
|
<version>${guava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-collections4</artifactId>
|
<artifactId>commons-collections4</artifactId>
|
||||||
<version>${commons-collections4.version}</version>
|
<version>${commons-collections4.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>${commons-lang3.version}</version>
|
<version>${commons-lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-math3</artifactId>
|
<artifactId>commons-math3</artifactId>
|
||||||
<version>${commons-math3.version}</version>
|
<version>${commons-math3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.decimal4j</groupId>
|
<groupId>org.decimal4j</groupId>
|
||||||
<artifactId>decimal4j</artifactId>
|
<artifactId>decimal4j</artifactId>
|
||||||
<version>${decimal4j.version}</version>
|
<version>${decimal4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>${bouncycastle.version}</version>
|
<version>${bouncycastle.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.unix4j</groupId>
|
<groupId>org.unix4j</groupId>
|
||||||
<artifactId>unix4j-command</artifactId>
|
<artifactId>unix4j-command</artifactId>
|
||||||
<version>${unix4j.version}</version>
|
<version>${unix4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.googlecode.grep4j</groupId>
|
<groupId>com.googlecode.grep4j</groupId>
|
||||||
<artifactId>grep4j</artifactId>
|
<artifactId>grep4j</artifactId>
|
||||||
<version>${grep4j.version}</version>
|
<version>${grep4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- web -->
|
<!-- web -->
|
||||||
|
|
||||||
<!-- marshalling -->
|
<!-- marshalling -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>1.2.17</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>${org.slf4j.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>${logback.version}</version>
|
<version>${logback.version}</version>
|
||||||
<!-- <scope>runtime</scope> -->
|
<!-- <scope>runtime</scope> -->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
<version>${org.slf4j.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>log4j-over-slf4j</artifactId>
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
<version>${org.slf4j.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- test scoped -->
|
<!-- test scoped -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>hamcrest-all</artifactId>
|
<artifactId>hamcrest-all</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>${junit.version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>hamcrest-core</artifactId>
|
<artifactId>hamcrest-core</artifactId>
|
||||||
<version>${org.hamcrest.version}</version>
|
<version>${org.hamcrest.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>hamcrest-library</artifactId>
|
<artifactId>hamcrest-library</artifactId>
|
||||||
<version>${org.hamcrest.version}</version>
|
<version>${org.hamcrest.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>${assertj.version}</version>
|
<version>${assertj.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>${mockito.version}</version>
|
<version>${mockito.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.awaitility</groupId>
|
<groupId>com.jayway.awaitility</groupId>
|
||||||
<artifactId>awaitility</artifactId>
|
<artifactId>awaitility</artifactId>
|
||||||
<version>${avaitility.version}</version>
|
<version>${avaitility.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>${commons-codec.version}</version>
|
<version>${commons-codec.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javamoney</groupId>
|
<groupId>org.javamoney</groupId>
|
||||||
<artifactId>moneta</artifactId>
|
<artifactId>moneta</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.owasp.esapi</groupId>
|
<groupId>org.owasp.esapi</groupId>
|
||||||
<artifactId>esapi</artifactId>
|
<artifactId>esapi</artifactId>
|
||||||
<version>2.1.0.1</version>
|
<version>2.1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
<version>1.4.196</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.messaging.mq</groupId>
|
|
||||||
<artifactId>fscontext</artifactId>
|
|
||||||
<version>${fscontext.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.codepoetics</groupId>
|
|
||||||
<artifactId>protonpack</artifactId>
|
|
||||||
<version>${protonpack.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>one.util</groupId>
|
|
||||||
<artifactId>streamex</artifactId>
|
|
||||||
<version>${streamex.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.vavr</groupId>
|
|
||||||
<artifactId>vavr</artifactId>
|
|
||||||
<version>${vavr.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-core</artifactId>
|
|
||||||
<version>1.19</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
|
||||||
<version>1.19</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-web</artifactId>
|
|
||||||
<version>4.3.4.RELEASE</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.messaging.mq</groupId>
|
||||||
|
<artifactId>fscontext</artifactId>
|
||||||
|
<version>${fscontext.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.codepoetics</groupId>
|
||||||
|
<artifactId>protonpack</artifactId>
|
||||||
|
<version>${protonpack.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>one.util</groupId>
|
||||||
|
<artifactId>streamex</artifactId>
|
||||||
|
<version>${streamex.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.vavr</groupId>
|
||||||
|
<artifactId>vavr</artifactId>
|
||||||
|
<version>${vavr.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>1.19</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>1.19</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
<version>4.3.4.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
<version>1.5.8.RELEASE</version>
|
<version>1.5.8.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hsqldb</groupId>
|
||||||
|
<artifactId>hsqldb</artifactId>
|
||||||
|
<version>2.4.0</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</dependencies>
|
<build>
|
||||||
|
<finalName>core-java</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
<build>
|
<plugins>
|
||||||
<finalName>core-java</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<configuration>
|
||||||
<configuration>
|
<excludes>
|
||||||
<source>1.8</source>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
<target>1.8</target>
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
</configuration>
|
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||||
</plugin>
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<configuration>
|
<executions>
|
||||||
<excludes>
|
<execution>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<id>copy-dependencies</id>
|
||||||
<exclude>**/*IntegrationTest.java</exclude>
|
<phase>prepare-package</phase>
|
||||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
<goals>
|
||||||
<exclude>**/*ManualTest.java</exclude>
|
<goal>copy-dependencies</goal>
|
||||||
</excludes>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</configuration>
|
<plugin>
|
||||||
</plugin>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathPrefix>libs/</classpathPrefix>
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>copy-dependencies</id>
|
<phase>package</phase>
|
||||||
<phase>prepare-package</phase>
|
<goals>
|
||||||
<goals>
|
<goal>single</goal>
|
||||||
<goal>copy-dependencies</goal>
|
</goals>
|
||||||
</goals>
|
<configuration>
|
||||||
<configuration>
|
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
|
||||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
<archive>
|
||||||
</configuration>
|
<manifest>
|
||||||
</execution>
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
</executions>
|
</manifest>
|
||||||
</plugin>
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<configuration>
|
<executions>
|
||||||
<archive>
|
<execution>
|
||||||
<manifest>
|
<goals>
|
||||||
<addClasspath>true</addClasspath>
|
<goal>shade</goal>
|
||||||
<classpathPrefix>libs/</classpathPrefix>
|
</goals>
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
<configuration>
|
||||||
</manifest>
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
</archive>
|
<transformers>
|
||||||
</configuration>
|
<transformer
|
||||||
</plugin>
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>com.jolira</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>onejar-maven-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<configuration>
|
||||||
<goals>
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
<goal>single</goal>
|
<attachToBuild>true</attachToBuild>
|
||||||
</goals>
|
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
|
||||||
<configuration>
|
</configuration>
|
||||||
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
|
<goals>
|
||||||
<archive>
|
<goal>one-jar</goal>
|
||||||
<manifest>
|
</goals>
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
</execution>
|
||||||
</manifest>
|
</executions>
|
||||||
</archive>
|
</plugin>
|
||||||
<descriptorRefs>
|
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
||||||
</descriptorRefs>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>shade</goal>
|
<goal>repackage</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
<classifier>spring-boot</classifier>
|
||||||
<transformers>
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
<transformer
|
</configuration>
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
</execution>
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
</executions>
|
||||||
</transformer>
|
</plugin>
|
||||||
</transformers>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.jolira</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>onejar-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<executions>
|
<version>1.6.0</version>
|
||||||
<execution>
|
<configuration>
|
||||||
<configuration>
|
<executable>java</executable>
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
<mainClass>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</mainClass>
|
||||||
<attachToBuild>true</attachToBuild>
|
<arguments>
|
||||||
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
|
<argument>-Xmx300m</argument>
|
||||||
</configuration>
|
<argument>-XX:+UseParallelGC</argument>
|
||||||
<goals>
|
<argument>-classpath</argument>
|
||||||
<goal>one-jar</goal>
|
<classpath/>
|
||||||
</goals>
|
<argument>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</argument>
|
||||||
</execution>
|
</arguments>
|
||||||
</executions>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<classifier>spring-boot</classifier>
|
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<version>1.6.0</version>
|
|
||||||
<configuration>
|
|
||||||
<executable>java</executable>
|
|
||||||
<mainClass>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</mainClass>
|
|
||||||
<arguments>
|
|
||||||
<argument>-Xmx300m</argument>
|
|
||||||
<argument>-XX:+UseParallelGC</argument>
|
|
||||||
<argument>-classpath</argument>
|
|
||||||
<classpath />
|
|
||||||
<argument>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>integration</id>
|
<id>integration</id>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>integration-test</phase>
|
<phase>integration-test</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>test</goal>
|
<goal>test</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*ManualTest.java</exclude>
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*IntegrationTest.java</include>
|
<include>**/*IntegrationTest.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<test.mime>json</test.mime>
|
<test.mime>json</test.mime>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>run-benchmarks</id>
|
<id>run-benchmarks</id>
|
||||||
<!-- <phase>integration-test</phase> -->
|
<!-- <phase>integration-test</phase>-->
|
||||||
<phase>none</phase>
|
<phase>none</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>exec</goal>
|
<goal>exec</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<classpathScope>test</classpathScope>
|
<classpathScope>test</classpathScope>
|
||||||
<executable>java</executable>
|
<executable>java</executable>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>-classpath</argument>
|
<argument>-classpath</argument>
|
||||||
<classpath />
|
<classpath/>
|
||||||
<argument>org.openjdk.jmh.Main</argument>
|
<argument>org.openjdk.jmh.Main</argument>
|
||||||
<argument>.*</argument>
|
<argument>.*</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- marshalling -->
|
<!-- marshalling -->
|
||||||
<jackson.version>2.8.5</jackson.version>
|
<jackson.version>2.8.5</jackson.version>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- logging -->
|
||||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
<logback.version>1.1.7</logback.version>
|
<logback.version>1.1.7</logback.version>
|
||||||
|
|
||||||
<!-- util -->
|
<!-- util -->
|
||||||
<guava.version>22.0</guava.version>
|
<guava.version>22.0</guava.version>
|
||||||
<commons-lang3.version>3.5</commons-lang3.version>
|
<commons-lang3.version>3.5</commons-lang3.version>
|
||||||
<bouncycastle.version>1.55</bouncycastle.version>
|
<bouncycastle.version>1.55</bouncycastle.version>
|
||||||
<commons-codec.version>1.10</commons-codec.version>
|
<commons-codec.version>1.10</commons-codec.version>
|
||||||
<commons-math3.version>3.6.1</commons-math3.version>
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
<decimal4j.version>1.0.3</decimal4j.version>
|
<decimal4j.version>1.0.3</decimal4j.version>
|
||||||
<commons-io.version>2.5</commons-io.version>
|
<commons-io.version>2.5</commons-io.version>
|
||||||
<commons-collections4.version>4.1</commons-collections4.version>
|
<commons-collections4.version>4.1</commons-collections4.version>
|
||||||
<collections-generic.version>4.01</collections-generic.version>
|
<collections-generic.version>4.01</collections-generic.version>
|
||||||
<unix4j.version>0.4</unix4j.version>
|
<unix4j.version>0.4</unix4j.version>
|
||||||
<grep4j.version>1.8.7</grep4j.version>
|
<grep4j.version>1.8.7</grep4j.version>
|
||||||
<lombok.version>1.16.12</lombok.version>
|
<lombok.version>1.16.12</lombok.version>
|
||||||
<fscontext.version>4.6-b01</fscontext.version>
|
<fscontext.version>4.6-b01</fscontext.version>
|
||||||
<protonpack.version>1.13</protonpack.version>
|
<protonpack.version>1.13</protonpack.version>
|
||||||
<streamex.version>0.6.5</streamex.version>
|
<streamex.version>0.6.5</streamex.version>
|
||||||
<vavr.version>0.9.0</vavr.version>
|
<vavr.version>0.9.0</vavr.version>
|
||||||
|
|
||||||
|
<!-- testing -->
|
||||||
|
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
<mockito.version>2.8.9</mockito.version>
|
||||||
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
<avaitility.version>1.7.0</avaitility.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- maven plugins -->
|
||||||
<org.hamcrest.version>1.3</org.hamcrest.version>
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
<junit.version>4.12</junit.version>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
<mockito.version>2.8.9</mockito.version>
|
</properties>
|
||||||
<assertj.version>3.6.1</assertj.version>
|
</project>
|
||||||
<avaitility.version>1.7.0</avaitility.version>
|
|
||||||
|
|
||||||
<!-- maven plugins -->
|
|
||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
|
||||||
</properties>
|
|
||||||
</project>
|
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.baeldung.jdbc;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BatchProcessing {
|
||||||
|
|
||||||
|
private final String[] EMPLOYEES = new String[]{"Zuck","Mike","Larry","Musk","Steve"};
|
||||||
|
private final String[] DESIGNATIONS = new String[]{"CFO","CSO","CTO","CEO","CMO"};
|
||||||
|
private final String[] ADDRESSES = new String[]{"China","York","Diego","Carolina","India"};
|
||||||
|
|
||||||
|
private Connection connection;
|
||||||
|
|
||||||
|
public void getConnection(){
|
||||||
|
try {
|
||||||
|
Class.forName("org.hsqldb.jdbcDriver");
|
||||||
|
connection = DriverManager.getConnection("jdbc:hsqldb:file:C:\\EMPLOYEEDB", "SA", "");
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createTables(){
|
||||||
|
try {
|
||||||
|
connection.createStatement().executeUpdate("create table EMPLOYEE (ID VARCHAR(36), NAME VARCHAR(45), DESIGNATION VARCHAR(15))");
|
||||||
|
connection.createStatement().executeUpdate("create table EMP_ADDRESS (ID VARCHAR(36), EMP_ID VARCHAR(36), ADDRESS VARCHAR(45))");
|
||||||
|
System.out.println("Tables Created!!!");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void useStatement(){
|
||||||
|
try {
|
||||||
|
String insertEmployeeSQL = "INSERT INTO EMPLOYEE(ID, NAME, DESIGNATION) VALUES ('%s','%s','%s');";
|
||||||
|
String insertEmployeeAddrSQL = "INSERT INTO EMP_ADDRESS(ID, EMP_ID, ADDRESS) VALUES ('%s','%s','%s');";
|
||||||
|
Statement statement = connection.createStatement();
|
||||||
|
for(int i = 0; i < EMPLOYEES.length; i++){
|
||||||
|
String employeeId = UUID.randomUUID().toString();
|
||||||
|
statement.addBatch(String.format(insertEmployeeSQL, employeeId, EMPLOYEES[i],DESIGNATIONS[i]));
|
||||||
|
statement.addBatch(String.format(insertEmployeeAddrSQL, UUID.randomUUID().toString(),employeeId,ADDRESSES[i]));
|
||||||
|
}
|
||||||
|
statement.executeBatch();
|
||||||
|
connection.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
connection.rollback();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("Error during rollback");
|
||||||
|
System.out.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usePreparedStatement(){
|
||||||
|
try {
|
||||||
|
String insertEmployeeSQL = "INSERT INTO EMPLOYEE(ID, NAME, DESIGNATION) VALUES (?,?,?);";
|
||||||
|
String insertEmployeeAddrSQL = "INSERT INTO EMP_ADDRESS(ID, EMP_ID, ADDRESS) VALUES (?,?,?);";
|
||||||
|
PreparedStatement employeeStmt = connection.prepareStatement(insertEmployeeSQL);
|
||||||
|
PreparedStatement empAddressStmt = connection.prepareStatement(insertEmployeeAddrSQL);
|
||||||
|
for(int i = 0; i < EMPLOYEES.length; i++){
|
||||||
|
String employeeId = UUID.randomUUID().toString();
|
||||||
|
employeeStmt.setString(1,employeeId);
|
||||||
|
employeeStmt.setString(2,EMPLOYEES[i]);
|
||||||
|
employeeStmt.setString(3,DESIGNATIONS[i]);
|
||||||
|
employeeStmt.addBatch();
|
||||||
|
|
||||||
|
empAddressStmt.setString(1,UUID.randomUUID().toString());
|
||||||
|
empAddressStmt.setString(2,employeeId);
|
||||||
|
empAddressStmt.setString(3,ADDRESSES[i]);
|
||||||
|
empAddressStmt.addBatch();
|
||||||
|
}
|
||||||
|
employeeStmt.executeBatch();
|
||||||
|
empAddressStmt.executeBatch();
|
||||||
|
connection.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
connection.rollback();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("Error during rollback");
|
||||||
|
System.out.println(ex.getMessage());
|
||||||
|
}
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
BatchProcessing batchProcessing = new BatchProcessing();
|
||||||
|
batchProcessing.getConnection();
|
||||||
|
batchProcessing.createTables();
|
||||||
|
batchProcessing.useStatement();
|
||||||
|
batchProcessing.usePreparedStatement();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package com.baeldung.jdbc;
|
||||||
|
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class BatchProcessingTest {
|
||||||
|
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private BatchProcessing target = new BatchProcessing();
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private Connection connection;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private Statement statement;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PreparedStatement employeeStatement;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PreparedStatement employeeAddressStatement;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before(){
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void when_useStatement_thenInsertData_success() throws Exception {
|
||||||
|
Mockito.when(connection.createStatement()).thenReturn(statement);
|
||||||
|
target.useStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void when_useStatement_ifThrowException_thenCatchException() throws Exception {
|
||||||
|
Mockito.when(connection.createStatement()).thenThrow(new RuntimeException());
|
||||||
|
target.useStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void when_usePreparedStatement_thenInsertData_success() throws Exception {
|
||||||
|
String insertEmployeeSQL = "INSERT INTO EMPLOYEE(ID, NAME, DESIGNATION) VALUES (?,?,?);";
|
||||||
|
String insertEmployeeAddrSQL = "INSERT INTO EMP_ADDRESS(ID, EMP_ID, ADDRESS) VALUES (?,?,?);";
|
||||||
|
Mockito.when(connection.prepareStatement(insertEmployeeSQL)).thenReturn(employeeStatement);
|
||||||
|
Mockito.when(connection.prepareStatement(insertEmployeeAddrSQL)).thenReturn(employeeAddressStatement);
|
||||||
|
target.usePreparedStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void when_usePreparedStatement_ifThrowException_thenCatchException() throws Exception {
|
||||||
|
String insertEmployeeSQL = "INSERT INTO EMPLOYEE(ID, NAME, DESIGNATION) VALUES (?,?,?);";
|
||||||
|
String insertEmployeeAddrSQL = "INSERT INTO EMP_ADDRESS(ID, EMP_ID, ADDRESS) VALUES (?,?,?);";
|
||||||
|
Mockito.when(connection.prepareStatement(insertEmployeeSQL)).thenReturn(employeeStatement);
|
||||||
|
Mockito.when(connection.prepareStatement(insertEmployeeAddrSQL)).thenThrow(new RuntimeException());
|
||||||
|
target.usePreparedStatement();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user