package dao; import Util.StringUtil; import model.Secondary; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class SecondaryDao { //学院添加 public int add(Connection con, Secondary secondary) throws Exception { String sql = "insert into secondary values(null,?,?)"; PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setString(1, secondary.getSecondary_name()); pstmt.setString(2, secondary.getSecondary_desc()); return pstmt.executeUpdate(); } //查询学院 public ResultSet list(Connection con, Secondary secondary) throws Exception { StringBuilder strb = new StringBuilder("select*from secondary"); if (StringUtil.isNotEmpty(secondary.getSecondary_name())) { strb.append(" and secondary_name like '%" + secondary.getSecondary_name() + "%'"); } PreparedStatement pstmt = con.prepareStatement(strb.toString().replace("and", "where")); return pstmt.executeQuery(); } //删除学院 public int delete(Connection con, String id) throws Exception { String sql = "delete from secondary where id=?"; PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setString(1, id); return pstmt.executeUpdate(); } //修改学院 public int update(Connection con, Secondary secondary) throws Exception { String sql = "update secondary set secondary_name=? ,secondary_desc=? where id =?"; PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setString(1, secondary.getSecondary_name()); pstmt.setString(2, secondary.getSecondary_desc()); pstmt.setInt(3, secondary.getId()); return pstmt.executeUpdate(); } }
最近下载更多
wanglinddad LV55
3月26日
weilaizhisheng LV21
2023年11月30日
卢本伟不开挂 LV4
2023年9月3日
微信网友_6000801142263808 LV3
2023年6月18日
wipeout LV1
2023年6月17日
mayong1234 LV6
2023年6月15日
huangzy LV12
2023年6月7日
lsglsg9 LV22
2023年6月4日
syfzsyfz LV1
2023年5月23日
全栈小白 LV34
2023年4月25日