diff --git a/libraries/pom.xml b/libraries/pom.xml index 90e01a53ab..6d41902db7 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -1,297 +1,297 @@ - - parent-modules - com.baeldung - 1.0.0-SNAPSHOT - - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 - libraries - libraries - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.felix - maven-bundle-plugin - 3.3.0 - maven-plugin + libraries + libraries + + + + org.apache.maven.plugins + maven-dependency-plugin + + + org.apache.felix + maven-bundle-plugin + 3.3.0 + maven-plugin - - - true - - - net.serenity-bdd.maven.plugins - serenity-maven-plugin - ${serenity.plugin.version} - - - serenity-reports - post-integration-test - - aggregate - - - - - - - org.datanucleus - datanucleus-maven-plugin - 5.0.2 - - JDO - ${basedir}/datanucleus.properties - ${basedir}/log4j.properties - true - - - - process-classes - - enhance - - - - - - + + + true + + + net.serenity-bdd.maven.plugins + serenity-maven-plugin + ${serenity.plugin.version} + + + serenity-reports + post-integration-test + + aggregate + + + + + + + org.datanucleus + datanucleus-maven-plugin + 5.0.2 + + JDO + ${basedir}/datanucleus.properties + ${basedir}/log4j.properties + true + + + + process-classes + + enhance + + + + + + - - - - cglib - cglib - ${cglib.version} - - - org.apache.commons - commons-lang3 - ${commons-lang.version} - - - org.jasypt - jasypt - ${jasypt.version} - - - org.javatuples - javatuples - ${javatuples.version} - - - org.javassist - javassist - ${javaassist.version} - - - - org.assertj - assertj-core - ${assertj.version} - - - org.skyscreamer - jsonassert - ${jsonassert.version} - - - org.javers - javers-core - ${javers.version} - - - org.eclipse.jetty - jetty-server - ${jetty.version} - - - org.eclipse.jetty - jetty-servlet - ${jetty.version} - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - commons-io - commons-io - ${commons.io.version} - - - org.apache.flink - flink-core - ${flink.version} - - - commons-logging - commons-logging - - - - - org.apache.flink - flink-java - ${flink.version} - - - commons-logging - commons-logging - - - - - org.apache.flink - flink-test-utils_2.10 - ${flink.version} - test - - - org.apache.commons - commons-math3 - 3.6.1 - - - net.serenity-bdd - serenity-core - ${serenity.version} - test - - - net.serenity-bdd - serenity-junit - ${serenity.version} - test - - - net.serenity-bdd - serenity-jbehave - ${serenity.jbehave.version} - test - - - net.serenity-bdd - serenity-rest-assured - ${serenity.version} - test - - - net.serenity-bdd - serenity-jira-requirements-provider - ${serenity.jira.version} - test - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - org.datanucleus - javax.jdo - 3.2.0-m6 - - - org.datanucleus - datanucleus-core - 5.1.0-m1 - - - org.datanucleus - datanucleus-api-jdo - 5.1.0-m1 - - - org.datanucleus - datanucleus-rdbms - 5.1.0-m1 - - - org.datanucleus - datanucleus-maven-plugin - 5.0.2 - - - com.h2database - h2 - 1.4.194 - - - org.datanucleus - datanucleus-xml - 5.0.0-release - - - org.springframework - spring-web - 4.3.8.RELEASE - - - net.serenity-bdd - serenity-spring - ${serenity.version} - test - - - io.rest-assured - spring-mock-mvc - 3.0.3 - test - - - org.multiverse - multiverse-core - ${multiverse.version} - - - com.zaxxer - HikariCP - 2.6.1 - compile - - - com.h2database - h2 - 1.4.195 - - - - 0.7.0 - 3.2.4 - 3.5 - 1.9.2 - 1.2 - 3.21.0-GA - 3.6.2 - 1.5.0 - 3.1.0 - 9.4.3.v20170317 - 4.5.3 - 2.5 - 9.4.2.v20170220 - 4.5.3 - 2.5 - 1.2.0 - 2.8.5 - 1.4.0 - 1.24.0 - 1.1.3-rc.5 - 1.4.0 - + + + + cglib + cglib + ${cglib.version} + + + org.apache.commons + commons-lang3 + ${commons-lang.version} + + + org.jasypt + jasypt + ${jasypt.version} + + + org.javatuples + javatuples + ${javatuples.version} + + + org.javassist + javassist + ${javaassist.version} + + + + org.assertj + assertj-core + ${assertj.version} + + + org.skyscreamer + jsonassert + ${jsonassert.version} + + + org.javers + javers-core + ${javers.version} + + + org.eclipse.jetty + jetty-server + ${jetty.version} + + + org.eclipse.jetty + jetty-servlet + ${jetty.version} + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + commons-io + commons-io + ${commons.io.version} + + + org.apache.flink + flink-core + ${flink.version} + + + commons-logging + commons-logging + + + + + org.apache.flink + flink-java + ${flink.version} + + + commons-logging + commons-logging + + + + + org.apache.flink + flink-test-utils_2.10 + ${flink.version} + test + + + org.apache.commons + commons-math3 + 3.6.1 + + + net.serenity-bdd + serenity-core + ${serenity.version} + test + + + net.serenity-bdd + serenity-junit + ${serenity.version} + test + + + net.serenity-bdd + serenity-jbehave + ${serenity.jbehave.version} + test + + + net.serenity-bdd + serenity-rest-assured + ${serenity.version} + test + + + net.serenity-bdd + serenity-jira-requirements-provider + ${serenity.jira.version} + test + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + org.datanucleus + javax.jdo + 3.2.0-m6 + + + org.datanucleus + datanucleus-core + 5.1.0-m1 + + + org.datanucleus + datanucleus-api-jdo + 5.1.0-m1 + + + org.datanucleus + datanucleus-rdbms + 5.1.0-m1 + + + org.datanucleus + datanucleus-maven-plugin + 5.0.2 + + + com.h2database + h2 + 1.4.194 + + + org.datanucleus + datanucleus-xml + 5.0.0-release + + + org.springframework + spring-web + 4.3.8.RELEASE + + + net.serenity-bdd + serenity-spring + ${serenity.version} + test + + + io.rest-assured + spring-mock-mvc + 3.0.3 + test + + + org.multiverse + multiverse-core + ${multiverse.version} + + + com.zaxxer + HikariCP + 2.6.1 + compile + + + com.h2database + h2 + 1.4.195 + + + + 0.7.0 + 3.2.4 + 3.5 + 1.9.2 + 1.2 + 3.21.0-GA + 3.6.2 + 1.5.0 + 3.1.0 + 9.4.3.v20170317 + 4.5.3 + 2.5 + 9.4.2.v20170220 + 4.5.3 + 2.5 + 1.2.0 + 2.8.5 + 1.4.0 + 1.24.0 + 1.1.3-rc.5 + 1.4.0 + diff --git a/libraries/src/main/java/com/baeldung/hikaricp/DataSource.java b/libraries/src/main/java/com/baeldung/hikaricp/DataSource.java index 524ea3fde3..ff4bc939aa 100644 --- a/libraries/src/main/java/com/baeldung/hikaricp/DataSource.java +++ b/libraries/src/main/java/com/baeldung/hikaricp/DataSource.java @@ -10,36 +10,36 @@ import com.zaxxer.hikari.HikariDataSource; public class DataSource { - private static HikariConfig config = new HikariConfig(); - private static HikariDataSource ds; + private static HikariConfig config = new HikariConfig(); + private static HikariDataSource ds; - static { -// config = new HikariConfig("datasource.properties"); - -// Properties props = new Properties(); -// props.setProperty("dataSourceClassName", "org.h2.Driver"); -// props.setProperty("dataSource.user", ""); -// props.setProperty("dataSource.password", ""); -// props.put("dataSource.logWriter", new PrintWriter(System.out)); -// config = new HikariConfig(props); - - config.setJdbcUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;INIT=runscript from 'classpath:/db.sql'"); - config.setUsername(""); - config.setPassword(""); - config.addDataSourceProperty("cachePrepStmts", "true"); - config.addDataSourceProperty("prepStmtCacheSize", "250"); - config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); - ds = new HikariDataSource(config); - -// ds.setJdbcUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;INIT=runscript from 'classpath:/db.sql'"); -// ds.setUsername(""); -// ds.setPassword(""); - } + static { +// config = new HikariConfig("datasource.properties"); + +// Properties props = new Properties(); +// props.setProperty("dataSourceClassName", "org.h2.Driver"); +// props.setProperty("dataSource.user", ""); +// props.setProperty("dataSource.password", ""); +// props.put("dataSource.logWriter", new PrintWriter(System.out)); +// config = new HikariConfig(props); + + config.setJdbcUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;INIT=runscript from 'classpath:/db.sql'"); + config.setUsername(""); + config.setPassword(""); + config.addDataSourceProperty("cachePrepStmts", "true"); + config.addDataSourceProperty("prepStmtCacheSize", "250"); + config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); + ds = new HikariDataSource(config); + +// ds.setJdbcUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;INIT=runscript from 'classpath:/db.sql'"); +// ds.setUsername(""); +// ds.setPassword(""); + } - private DataSource() {} + private DataSource() {} - public static Connection getConnection() throws SQLException { - return ds.getConnection(); - } + public static Connection getConnection() throws SQLException { + return ds.getConnection(); + } -} \ No newline at end of file +} diff --git a/libraries/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java b/libraries/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java index 1369f08959..af36ab7508 100644 --- a/libraries/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java +++ b/libraries/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java @@ -9,34 +9,34 @@ import java.util.List; public class HikariCPDemo { - public static List fetchData() { - final String SQL_QUERY = "select * from emp"; - List employees = null; - try (Connection con = DataSource.getConnection(); - PreparedStatement pst = con.prepareStatement(SQL_QUERY); - ResultSet rs = pst.executeQuery();) { - employees = new ArrayList(); - Employee employee; - while (rs.next()) { - employee = new Employee(); - employee.setEmpNo(rs.getInt("empno")); - employee.setEname(rs.getString("ename")); - employee.setJob(rs.getString("job")); - employee.setMgr(rs.getInt("mgr")); - employee.setHiredate(rs.getDate("hiredate")); - employee.setSal(rs.getInt("sal")); - employee.setComm(rs.getInt("comm")); - employee.setDeptno(rs.getInt("deptno")); - employees.add(employee); - } - } catch (SQLException e) { - e.printStackTrace(); - } - return employees; - } + public static List fetchData() { + final String SQL_QUERY = "select * from emp"; + List employees = null; + try (Connection con = DataSource.getConnection(); + PreparedStatement pst = con.prepareStatement(SQL_QUERY); + ResultSet rs = pst.executeQuery();) { + employees = new ArrayList(); + Employee employee; + while (rs.next()) { + employee = new Employee(); + employee.setEmpNo(rs.getInt("empno")); + employee.setEname(rs.getString("ename")); + employee.setJob(rs.getString("job")); + employee.setMgr(rs.getInt("mgr")); + employee.setHiredate(rs.getDate("hiredate")); + employee.setSal(rs.getInt("sal")); + employee.setComm(rs.getInt("comm")); + employee.setDeptno(rs.getInt("deptno")); + employees.add(employee); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return employees; + } - public static void main(String[] args) { - fetchData(); - } - -} \ No newline at end of file + public static void main(String[] args) { + fetchData(); + } + +} diff --git a/libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java b/libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java index 7ac94edc76..0e29e3390a 100644 --- a/libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java +++ b/libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java @@ -8,10 +8,10 @@ import static org.junit.Assert.assertEquals; public class HikariCPUnitTest { - @Test - public void givenConnection_thenFetchDbData() { - List employees = HikariCPDemo.fetchData(); - assertEquals(4, employees.size()); - } + @Test + public void givenConnection_thenFetchDbData() { + List employees = HikariCPDemo.fetchData(); + assertEquals(4, employees.size()); + } }