angelia_wyy_wyy
一个做运维的girl
2016-07-19 14:27

java 多表查询代码 运行没反应

10

oracle 表
create table dept(deptno int primary key,dname varchar(20),loc varchar(30));
create table emp(empno int,ename varchar(30),job varchar(20),hiredate date,sal float,comm float
deptno int,mgr int,
primary key(empno),
foreign key(deptno) references dept(deptno),
foreign key(mgr) references emp(empno)
);

部分代码:
private Connection conn;
private PreparedStatement pstmt;
public EmpDAOImpl(Connection conn) {
this.conn=conn;
}
@Override
public boolean doCreate(Emp vo) throws Exception {
String sql="INSERT INTO emp(empno,ename,job,hiredate,sal,comm,mgr,deptno) VALUES(?,?,?,?,?,?,?,?)";
pstmt=this.conn.prepareStatement(sql);

    pstmt.setInt(1, vo.getEmpno());
    pstmt.setString(2, vo.getEname());
    pstmt.setString(3, vo.getJob());
    pstmt.setDate(4, new java.sql.Date(vo.getHiredate().getTime()) );
    pstmt.setDouble(5, vo.getSal());
    pstmt.setDouble(6, vo.getComm());

    Emp mgr=vo.getMgr();
    if(mgr==null)
        pstmt.setNull(7, Types.NULL);
    else
        pstmt.setInt(7, mgr.getEmpno());

    Dept dept= vo.getDept();
    if(dept==null)
        pstmt.setNull(8,Types.NULL);
    else 
        pstmt.setInt(8, dept.getDeptno());
    return pstmt.executeUpdate()>0;

}
为什么运行这个方法时一直运行没出结果
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答