首页 技术 正文
技术 2022年11月16日
0 收藏 684 点赞 2,111 浏览 2032 个字

Java课程设计——学生成绩管理系统(201521123003 董美凤)

1.团队课程设计博客链接

学生成绩管理系统博客链接

2.个人负责模块或任务说明

  • 信息修改
  • 密码修改
  • 部分界面设计

3.自己的代码提交记录截图

码云项目地址

4.自己负责模块或任务详细说明

  • 学生信息修改
@Override
public int update(String stuno, String name, String sex, String birthday) {
// TODO Auto-generated method stub
int result=-1;
Connection conn = null;
Statement st= null;
ResultSet resultset=null;
String sqlname = "update students set name='"+name+"'where stuno="+stuno;
String sqlsex="update students set sex='"+sex+"' where stuno="+stuno;
String sqlbirthday="update students set birthday='"+birthday+"' where stuno="+stuno;
try {
conn = JDBCUtil.getConnection();
st = conn.createStatement();
if(!name.isEmpty()){
int i=st.executeUpdate(sqlname);
result=1;
}
if(!sex.isEmpty()){
int i=st.executeUpdate(sqlsex);
result=1;
}
if(!birthday.isEmpty()){
int i=st.executeUpdate(sqlbirthday);
result=1;
}}catch (SQLException sqle) {
sqle.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}finally{
JDBCUtil.realeaseAll(null,st, conn);
}
return result;
}

从界面文本框中请求相关数据,调用update()方法,方法内判断获取的字符串是否为空,不为空则将相关MySqL修改信息语句写入数据库进行更改学生信息。

  • 密码修改
@Override
public int changepassword(String stuno, String oldpassword,String newpassword1, String newpassword2) {
// TODO Auto-generated method stub
int result=-1;
String password=null;
Connection conn = null;
Statement st= null;
ResultSet rs=null;
String sqlchange = "update students set password='"+newpassword1+"'where stuno="+stuno;
String sqlgetpassword="select * from students where stuno="+stuno;
try {
conn = JDBCUtil.getConnection();
st = conn.createStatement();
rs = st.executeQuery(sqlgetpassword);
while(rs.next())
password=rs.getString("password");
if(!newpassword1.isEmpty()&&!newpassword2.isEmpty()&&oldpassword.equals(password)){
result=st.executeUpdate(sqlchange);
}
}catch (SQLException sqle) {
sqle.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}finally{
JDBCUtil.realeaseAll(null,st, conn);
}
return result;
}

用户将所知原密码输入,并输入新密码和确认密码,调用changepassword()方法,该方法将数据库中的相关用户密码读出并与用户所输密码进行比较,同时新密码和确认密码不为空并且相等,同时满足这些条件,才对数据库中的用户的密码进行修改。

5.课程设计感想

巩固了所学的知识,对Java的认知有了新的认知,对整个项目的框架构建设计有了更清晰的认识。同时,在遇到问题,不断修改代码,不断尝试不同的思维方式去解决问题的过程中,收获颇多。最重要的是,与队友一起熬夜解决问题,一同谈论、学习、分享的感觉非常好,由于时间紧凑,功能和界面较为简洁,未能够对其进行更好地完善。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918