public void del(Integer empId, String yearMonth) {
Connection conn=DBUtil.getInstance().getConn();
PreparedStatement pstmt=null;
try {
pstmt=conn.prepareStatement("delete from t_salary where emp_id=? and year_month=?");
pstmt.setInt(1, empId);
pstmt.setString(2, yearMonth);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw new DataAcessException("工资信息删除失败!!!");
}
finally{
DBUtil.getInstance().release(conn, pstmt, null);
}


}总是select 语句总是不起作用,要删除的记录删除不了,不懂的哪里错了,郁闷呐。

解决方案 »

  1.   

    事物是默认的吧,delete from t_salary where emp_id=? and year_month=?,带上你的值,在数据库端直接执行看看还能删掉东西啊,代码看上去没什么问题啊
      

  2.   

    直接调试或者打印出来sql在数据库查一下吧
      

  3.   

    什么叫总是select 语句总是不起作用
      

  4.   

    1.你传进方法中的yearMonth,和数据库里的year_month类型和格式一样么?2.还有就是2楼说的,把sql语句在数据库上直接运行看效果。3.贴报错信息,大家好帮你分析。