From 514164a86166af3310010761fa66c899eebd7092 Mon Sep 17 00:00:00 2001 From: Zeger Hendrikse Date: Mon, 15 May 2017 20:38:58 +0200 Subject: [PATCH] Removed dead code --- .../com/baeldung/hikaricp/DataSource.java | 48 ------------- .../java/com/baeldung/hikaricp/Employee.java | 72 ------------------- .../com/baeldung/hikaricp/HikariCPDemo.java | 38 ---------- .../main/java/com/baeldung/hikaricp/db.sql | 47 ------------ 4 files changed, 205 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/hikaricp/DataSource.java delete mode 100644 core-java/src/main/java/com/baeldung/hikaricp/Employee.java delete mode 100644 core-java/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java delete mode 100644 core-java/src/main/java/com/baeldung/hikaricp/db.sql diff --git a/core-java/src/main/java/com/baeldung/hikaricp/DataSource.java b/core-java/src/main/java/com/baeldung/hikaricp/DataSource.java deleted file mode 100644 index 996f528172..0000000000 --- a/core-java/src/main/java/com/baeldung/hikaricp/DataSource.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.hikaricp; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Properties; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; - -public class DataSource { - - private static HikariConfig config = new HikariConfig(); - private static HikariDataSource ds; - - static { -// config = new HikariConfig("datasource.properties"); - -// Properties props = new Properties(); -// props.setProperty("dataSourceClassName", "org.postgresql.ds.PGSimpleDataSource"); -// props.setProperty("dataSource.user", "postgres"); -// props.setProperty("dataSource.password", "postgres"); -// props.setProperty("dataSource.databaseName", "postgres"); -// props.setProperty("dataSource.portNumber", "5432"); -// props.setProperty("dataSource.serverName", "localhost"); -// props.put("dataSource.logWriter", new PrintWriter(System.out)); -// config = new HikariConfig(props); - - config.setJdbcUrl("jdbc:postgresql://localhost:5432/postgres"); - config.setUsername("postgres"); - config.setPassword("postgres"); - config.addDataSourceProperty("cachePrepStmts", "true"); - config.addDataSourceProperty("prepStmtCacheSize", "250"); - config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); - ds = new HikariDataSource(config); - -// ds.setJdbcUrl("jdbc:postgresql://localhost:5432/postgres"); -// ds.setUsername("postgres"); -// ds.setPassword("postgres"); - } - - private DataSource() {} - - public static Connection getConnection() throws SQLException { - return ds.getConnection(); - } - -} diff --git a/core-java/src/main/java/com/baeldung/hikaricp/Employee.java b/core-java/src/main/java/com/baeldung/hikaricp/Employee.java deleted file mode 100644 index 5472d5c18c..0000000000 --- a/core-java/src/main/java/com/baeldung/hikaricp/Employee.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.baeldung.hikaricp; - -import java.sql.Date; - -public class Employee { - - private int empNo; - private String ename; - private String job; - private int mgr; - private Date hiredate; - private int sal; - private int comm; - private int deptno; - - public int getEmpNo() { - return empNo; - } - public void setEmpNo(int empNo) { - this.empNo = empNo; - } - public String getEname() { - return ename; - } - public void setEname(String ename) { - this.ename = ename; - } - - public String getJob() { - return job; - } - public void setJob(String job) { - this.job = job; - } - public int getMgr() { - return mgr; - } - public void setMgr(int mgr) { - this.mgr = mgr; - } - public Date getHiredate() { - return hiredate; - } - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - public int getSal() { - return sal; - } - public void setSal(int sal) { - this.sal = sal; - } - public int getComm() { - return comm; - } - public void setComm(int comm) { - this.comm = comm; - } - public int getDeptno() { - return deptno; - } - public void setDeptno(int deptno) { - this.deptno = deptno; - } - - @Override - public String toString() { - return "Employee [empNo=" + empNo + ", ename=" + ename + ", job=" + job + ", mgr=" + mgr + ", hiredate=" - + hiredate + ", sal=" + sal + ", comm=" + comm + ", deptno=" + deptno + "]"; - } - -} diff --git a/core-java/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java b/core-java/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java deleted file mode 100644 index 97b5bf5644..0000000000 --- a/core-java/src/main/java/com/baeldung/hikaricp/HikariCPDemo.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.hikaricp; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -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; - } - -} diff --git a/core-java/src/main/java/com/baeldung/hikaricp/db.sql b/core-java/src/main/java/com/baeldung/hikaricp/db.sql deleted file mode 100644 index 1dac59307b..0000000000 --- a/core-java/src/main/java/com/baeldung/hikaricp/db.sql +++ /dev/null @@ -1,47 +0,0 @@ -create table dept( - deptno numeric, - dname varchar(14), - loc varchar(13), - constraint pk_dept primary key (deptno) -); - -create table emp( - empno numeric, - ename varchar(10), - job varchar(9), - mgr numeric, - hiredate date, - sal numeric, - comm numeric, - deptno numeric, - constraint pk_emp primary key (empno), - constraint fk_deptno foreign key (deptno) references dept (deptno) -); - -insert into dept values(10, 'ACCOUNTING', 'NEW YORK'); -insert into dept values(20, 'RESEARCH', 'DALLAS'); -insert into dept values(30, 'SALES', 'CHICAGO'); -insert into dept values(40, 'OPERATIONS', 'BOSTON'); - -insert into emp values( - 7839, 'KING', 'PRESIDENT', null, - to_date('17-11-1981','dd-mm-yyyy'), - 7698, null, 10 -); -insert into emp values( - 7698, 'BLAKE', 'MANAGER', 7839, - to_date('1-5-1981','dd-mm-yyyy'), - 7782, null, 20 -); -insert into emp values( - 7782, 'CLARK', 'MANAGER', 7839, - to_date('9-6-1981','dd-mm-yyyy'), - 7566, null, 30 -); -insert into emp values( - 7566, 'JONES', 'MANAGER', 7839, - to_date('2-4-1981','dd-mm-yyyy'), - 7839, null, 40 -); - -commit; \ No newline at end of file