1
//修改方法
public void udateEmp(Emp emp) { //连接数据库 Connection con=null; PreparedStatement pstm=null; String sql=null; try { con=DBUtil.getConnection(); sql="update t_emp set name=?,age=?,sal=? where id=?";
2
pstm=con.prepareStatement(sql); pstm.setString(1, emp.getName()); pstm.setInt(2, emp.getAge()); pstm.setDouble(3, emp.getSal()); pstm.setInt(4, emp.getId()); pstm.executeUpdate(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ DBUtil.closeConnection(con); } }
3
多个se