- public class DeptDao {
- public int a dd(Connection conn, Dept dept) throws Exception {
- String sql = "insert into dept values(?,?,?,)";
- PreparedStatement pst = conn.prepareStatement(sql);
- pst.setInt(1, dept.getDeptno());
- pst.setString(2,dept.getDname());
- pst.setString(3, dept.getLoc());
- return pst.executeUpdate();
- }
- public int modify(Connection conn, Dept dept) throws Exception {
- String sql = "Update dept set dname=?,loc=?where deptno=?;
- PrepareStstement pst=conn.prepareStatement(sql);
- pst.setString(1,dept.getDname());
- pst.setString(2,dept.getLoc());
- pst.setInt(3,dept.getDeptno());
- int i=pst.executeUpdate();
- return i;"