删除:未使用代码
This commit is contained in:
parent
18a584f73e
commit
c03ded4930
@ -75,35 +75,6 @@ public class StudentDAOImpl implements StudentDAO {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学生信息
|
||||
* 根据学生对象的ID更新其他字段的值
|
||||
*
|
||||
* @param student 包含更新信息的学生对象
|
||||
* @return 影响的行数,更新成功返回1,失败返回0
|
||||
*/
|
||||
@Override
|
||||
public int update(Student student) {
|
||||
String sql = "UPDATE students SET student_id = ?, name = ?, class_name = ?, contact = ?, college = ?, major = ?, password = ? WHERE id = ?";
|
||||
try (Connection conn = DatabaseUtil.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
// 设置预处理语句的参数
|
||||
stmt.setString(1, student.getStudentId());
|
||||
stmt.setString(2, student.getName());
|
||||
stmt.setString(3, student.getClassName());
|
||||
stmt.setString(4, student.getContact());
|
||||
stmt.setString(5, student.getCollege());
|
||||
stmt.setString(6, student.getMajor());
|
||||
stmt.setString(7, student.getPassword());
|
||||
stmt.setInt(8, student.getId());
|
||||
|
||||
return stmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询学生信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user