当前位置:Gxlcms > 数据库问题 > 用JAVA给数据库增加和修改数据代码

用JAVA给数据库增加和修改数据代码

时间:2021-07-01 10:21:17 帮助过:4人阅读

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;

 

用JAVA给数据库增加和修改数据代码

标签:into   where   get   ring   nec   tin   date   pre   insert   

人气教程排行