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;
}
@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;
}
5.课程设计感想