package dao;
import Util.StringUtil;
import model.StudentClass;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class StudentClassDao {
//班级添加
public int add(Connection con, StudentClass studentClass) throws Exception {
String sql = "Insert into studentClass values(null,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, studentClass.getStudentClass_name());
pstmt.setString(2, studentClass.getStudentClass_desc());
return pstmt.executeUpdate();
}
//查询班级
public ResultSet list(Connection con, StudentClass studentClass) throws Exception {
StringBuilder stub = new StringBuilder("select * from studentClass");
if (StringUtil.isNotEmpty(studentClass.getStudentClass_name())) {
stub.append(" and studentClass_name like '%" + studentClass.getStudentClass_name() + "%'");
}
PreparedStatement pstmt = con.prepareStatement(stub.toString().replace("and", "where"));
return pstmt.executeQuery();
}
//删除学院
public int delete(Connection con, String id) throws Exception {
String sql = "delete from studentclass where id=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, id);
return pstmt.executeUpdate();
}
//修改班级
public int update(Connection con, StudentClass studentClass) throws Exception {
String sql = "update studentclass set studentclass_name=? ,studentclass_desc=? where id =?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, studentClass.getStudentClass_name());
pstmt.setString(2, studentClass.getStudentClass_desc());
pstmt.setInt(3, studentClass.getId());
return pstmt.executeUpdate();
}
}
最近下载更多
wahukkk LV1
6月23日
随便取个名字_哈哈 LV27
6月23日
pxqtsht LV16
2月21日
120_wu LV4
2024年12月3日
srl2881552 LV10
2024年11月25日
wanglinddad LV55
2024年3月26日
weilaizhisheng LV21
2023年11月30日
卢本伟不开挂 LV4
2023年9月3日
微信网友_6000801142263808 LV3
2023年6月18日
wipeout LV1
2023年6月17日
最近浏览更多
随便取个名字_哈哈 LV27
6月23日
wahukkk LV1
6月22日
没有啊很开心啊 LV4
3月10日
docnnxxy688
3月1日
暂无贡献等级
pxqtsht LV16
2月21日
短巷拥猫 LV12
2024年12月23日
571818771 LV3
2024年12月17日
120_wu LV4
2024年12月3日
srl2881552 LV10
2024年11月25日
summer0613
2024年11月19日
暂无贡献等级

