引言
JDBC技术(一)——一个简单的JDBC测试,在这篇博客中,我们发现,每完成一个查询时都需要去写对应的代码,而且还有许多重复的。这样做工作效率既不高,而且还显得很乱。所以我们对其进行修改简化。
前期准备
1、和上面博客一样
2、新建resources目录并标记为资源文件的根目录,创建jdbc配置文件
项目结构
编写代码
1、实体类
public class Emp2 implements Serializable {
private Integer empno;
private String ename;
private String job;
private Integer mgr;
private LocalDateTime hiredate;
private BigDecimal sal;
private BigDecimal comm;
private Integer deptno;
public Emp2() {
}
public Emp2(Integer empno, String ename, String job, Integer mgr, LocalDateTime hiredate, BigDecimal sal, BigDecimal comm, Integer deptno) {
this.empno = empno;
this.ename = ename;
this.job = job;
this.mgr = mgr;
this.hiredate = hiredate;
this.sal = sal;
this.comm = comm;
this.deptno = deptno;
}
@Override
public String toString() {
return "Emp{" +
"empno=" + empno +
", ename='" + ename + '\'' +
", job='" + job + '\'' +
", mgr=" + mgr +
", hiredate=" + hiredate +
", sal=" + sal +
", comm=" + comm +
", deptno=" + deptno +
'}';
}
public Integer getDeptno() {
return deptno;
}
public void setDeptno(Integer deptno) {
this.deptno = deptno;
}
public Integer getEmpno() {
return empno;
}
public void setEmpno(Integer 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 Integer getMgr() {
return mgr;
}
public void setMgr(Integer mgr) {
this.mgr = mgr;
}
public