Java課程設計——學生成績管理系統(201521123003 董美鳳)


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的認知有了新的認知,對整個項目的框架構建設計有了更清晰的認識。同時,在遇到問題,不斷修改代碼,不斷嘗試不同的思維方式去解決問題的過程中,收獲頗多。最重要的是,與隊友一起熬夜解決問題,一同談論、學習、分享的感覺非常好,由於時間緊湊,功能和界面較為簡潔,未能夠對其進行更好地完善。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM