实例介绍
【实例简介】源码在ResumeSystem.war文件中,解压该文件即可看到源码
【实例截图】
【实例截图】
【核心代码】
package ResumeSystem.module; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.*; import java.text.*; import javax.servlet.http.HttpSession; import ResumeSystem.*; public class MResume extends MCommon { //guest登录简历的情况 public boolean registerGuestResume ( HttpSession mySession, ResumeContent resumeObj ) { //设置用户信息 Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_GUEST_REGISTER); //登录简历 ResumeContent resumeFinish = register( mySession, resumeObj); //如果登录成功 if ( resumeFinish.getResumeId() != null && resumeFinish.getResumeId().length() > 0 ) { myValues.put( "resume", resumeFinish ); return true; } else { myValues.put( "resume", resumeObj); return false; } } //管理员登录简历的情况 public boolean registerAdminResume ( HttpSession mySession, ResumeContent resumeObj ) { //设置用户信息 Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_REGISTER_DETAIL); //登录简历 ResumeContent resumeFinish = register( mySession, resumeObj); //如果登录成功 if ( resumeFinish.getResumeId() != null && resumeFinish.getResumeId().length() > 0 ) { myValues.put( "resume", resumeFinish ); return true; } else { myValues.put( "resume", resumeObj); return false; } } //登录简历 private synchronized ResumeContent register( HttpSession mySession, ResumeContent resumeObj) { //获得数据库连接 Connection conn = this.getDBConnection( mySession ); if ( conn == null ) { return resumeObj; } Statement stmt = null; ResultSet rs = null; try { //得到当前系统时间 String sDate = (new SimpleDateFormat("yyyy/MM/dd")).format(new Date(System.currentTimeMillis())); //获得数据库中简历的最大id String sResumeId = ""; stmt = conn.createStatement(); //执行SQL语句 String sQuery = "select max(resume_id) from resume"; rs = stmt.executeQuery( sQuery ); rs.next(); String sCurrentMaxId = rs.getString(1); //当前是第一次登录 if ( sCurrentMaxId == null ) { sResumeId = "00000001"; } else { int iMaxCd = Integer.parseInt(sCurrentMaxId); sResumeId = String.valueOf(iMaxCd 1); int iLength = sResumeId.length(); for(int i=8; i>iLength; i--) { sResumeId = "0" sResumeId; } } //尝试插入数据库 StringBuffer sInsertSQL = new StringBuffer(); sInsertSQL.append( "insert into resume set "); sInsertSQL.append( "resume_id = '" sResumeId "', "); sInsertSQL.append( "realname = '" resumeObj.getRealname() "', " ); sInsertSQL.append( "sex = '" resumeObj.getSex() "', " ); sInsertSQL.append( "born_date = '" resumeObj.getBornDate() "', " ); sInsertSQL.append( "max_education = '" resumeObj.getMaxEducation() "', " ); sInsertSQL.append( "major = '" resumeObj.getMajor() "', " ); sInsertSQL.append( "email = '" resumeObj.getEmail() "', " ); sInsertSQL.append( "contact_phone = '" resumeObj.getContactPhone() "', " ); sInsertSQL.append( "mobile = '" resumeObj.getMobile() "', " ); sInsertSQL.append( "current_job_type = '" resumeObj.getCurrentJobType() "', " ); sInsertSQL.append( "expect_job_type = '" resumeObj.getExpectJobType() "', " ); sInsertSQL.append( "current_position = '" resumeObj.getCurrentPosition() "', " ); sInsertSQL.append( "expect_position = '" resumeObj.getExpectPosition() "', " ); sInsertSQL.append( "current_city = '" resumeObj.getCurrentCity() "', " ); sInsertSQL.append( "expect_city = '" resumeObj.getExpectCity() "', " ); sInsertSQL.append( "expect_salary = '" resumeObj.getExpectSalary() "', " ); sInsertSQL.append( "resume_content = '" resumeObj.getResumeContent() "', " ); sInsertSQL.append( "expire_time = '" resumeObj.getExpireTime() "', " ); sInsertSQL.append( "add_time = '" sDate "'" ); stmt.executeUpdate( sInsertSQL.toString() ); resumeObj.setResumeId(sResumeId); return resumeObj; } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","往数据库中添加新简历的时候出现错误,请联系技术人员!"); return resumeObj; } finally { try { rs.close(); stmt.close(); conn.close(); }catch(Exception ex) { } } } //得到所有未处理的简历一览 public boolean getAllProcessResume( HttpSession mySession ) { //设置用户信息 Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_PROCESS_LIST); //获得数据库连接 Connection conn = this.getDBConnection( mySession ); if ( conn == null ) { return false; } Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); //执行SQL语句 String sQuery = "select * from resume where expire_time='' order by resume_id desc"; rs = stmt.executeQuery( sQuery ); Vector processResumes = new Vector(); //循环取得所有未整理的简历 while ( rs.next() ) { ResumeContent resumeObj = new ResumeContent(); resumeObj.setResumeId( rs.getString("resume_id") ); resumeObj.setRealname( rs.getString("realname") ); resumeObj.setSex( rs.getString("sex") ); resumeObj.setBornDate( rs.getString("born_date") ); resumeObj.setMaxEducation( rs.getString("max_education") ); resumeObj.setMajor( rs.getString("major") ); resumeObj.setEmail( rs.getString("email") ); resumeObj.setContactPhone( rs.getString("contact_phone") ); resumeObj.setMobile( rs.getString("mobile") ); resumeObj.setCurrentJobType( rs.getString("current_job_type") ); resumeObj.setExpectJobType( rs.getString("expect_job_type") ); resumeObj.setCurrentPosition( rs.getString("current_position") ); resumeObj.setExpectPosition( rs.getString("expect_position") ); resumeObj.setCurrentCity( rs.getString("current_city") ); resumeObj.setExpectCity( rs.getString("expect_city") ); resumeObj.setExpectSalary( rs.getString("expect_salary") ); resumeObj.setResumeContent( rs.getString("resume_content") ); resumeObj.setAddTime( rs.getString("add_time") ); processResumes.add( resumeObj ); } //放入页面值域 myValues.put( "resumes", processResumes ); //计算总页数 int countPerPage = ((Integer)mySession.getAttribute( "countPerPage" )).intValue(); int totalResumes = processResumes.size(); int totalPage = 0; if ( totalResumes % countPerPage == 0 ) { totalPage = totalResumes/countPerPage; } else { totalPage = totalResumes/countPerPage 1; } int curPage = 0; //放入当前页码 myValues.put( "curPage", new Integer(curPage) ); //放入总页码 myValues.put( "totalPage", new Integer(totalPage) ); return true; } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","在数据库中查找待处理简历的时候出现错误,请联系技术人员!"); return false; } finally { try { rs.close(); stmt.close(); conn.close(); }catch(Exception ex) { } } } //设置用户过期时间 public boolean processResume( HttpSession mySession, String resumeId, String expireTime) { //获得数据库连接 Connection conn = this.getDBConnection( mySession ); if ( conn == null ) { return false; } Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); //尝试修改数据库 String sUpdateSQL = "update resume set expire_time='" expireTime "' where resume_id='" resumeId "'"; stmt.executeUpdate( sUpdateSQL ); return true; } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","处理简历的时候出现错误,请联系技术人员!"); return false; } finally { try { rs.close(); stmt.close(); conn.close(); }catch(Exception ex) { } } } //删除简历 public boolean deleteResume( HttpSession mySession, String resumeId ) { //获得数据库连接 Connection conn = this.getDBConnection( mySession ); if ( conn == null ) { return false; } Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); //尝试修改数据库 String sUpdateSQL = "delete from resume where resume_id='" resumeId "'"; stmt.executeUpdate( sUpdateSQL ); return true; } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","抛弃简历的时候出现错误,请联系技术人员!"); return false; } finally { try { rs.close(); stmt.close(); conn.close(); }catch(Exception ex) { } } } //得到所有过期简历一览 public boolean getAllExpireResume( HttpSession mySession ) { //设置用户信息 Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_EXPIRE_LIST); //获得数据库连接 Connection conn = this.getDBConnection( mySession ); if ( conn == null ) { return false; } Statement stmt = null; ResultSet rs = null; try { //得到当前系统时间 String sDate = (new SimpleDateFormat("yyyy/MM/dd")).format(new Date(System.currentTimeMillis())); stmt = conn.createStatement(); //执行SQL语句 String sQuery = "select * from resume where expire_time<>'' and expire_time<'" sDate "' order by resume_id desc"; rs = stmt.executeQuery( sQuery ); Vector processResumes = new Vector(); //循环取得所有过期的简历 while ( rs.next() ) { ResumeContent resumeObj = new ResumeContent(); resumeObj.setResumeId( rs.getString("resume_id") ); resumeObj.setRealname( rs.getString("realname") ); resumeObj.setSex( rs.getString("sex") ); resumeObj.setBornDate( rs.getString("born_date") ); resumeObj.setMaxEducation( rs.getString("max_education") ); resumeObj.setMajor( rs.getString("major") ); resumeObj.setEmail( rs.getString("email") ); resumeObj.setContactPhone( rs.getString("contact_phone") ); resumeObj.setMobile( rs.getString("mobile") ); resumeObj.setCurrentJobType( rs.getString("current_job_type") ); resumeObj.setExpectJobType( rs.getString("expect_job_type") ); resumeObj.setCurrentPosition( rs.getString("current_position") ); resumeObj.setExpectPosition( rs.getString("expect_position") ); resumeObj.setCurrentCity( rs.getString("current_city") ); resumeObj.setExpectCity( rs.getString("expect_city") ); resumeObj.setExpectSalary( rs.getString("expect_salary") ); resumeObj.setResumeContent( rs.getString("resume_content") ); resumeObj.setExpireTime( rs.getString("expire_time") ); resumeObj.setAddTime( rs.getString("add_time") ); processResumes.add( resumeObj ); } //放入页面值域 myValues.put( "resumes", processResumes ); //计算总页数 int countPerPage = ((Integer)mySession.getAttribute( "countPerPage" )).intValue(); int totalResumes = processResumes.size(); int totalPage = 0; if ( totalResumes % countPerPage == 0 ) { totalPage = totalResumes/countPerPage; } else { totalPage = totalResumes/countPerPage 1; } int curPage = 0; //放入当前页码 myValues.put( "curPage", new Integer(curPage) ); //放入总页码 myValues.put( "totalPage", new Integer(totalPage) ); return true; } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","在数据库中查找过期简历的时候出现错误,请联系技术人员!"); return false; } finally { try { rs.close(); stmt.close(); conn.close(); }catch(Exception ex) { } } } //根据检索条件获得对应的简历 public boolean searchResume( HttpSession mySession, String sResumeId1, String sResumeId2, String sRealname, String sSex, String sMaxEducation, String sMajor, String sCurrentJobType, String sCurrentCity ) { //设置用户信息 Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_VIEW_LIST); //获得数据库连接 Connection conn = this.getDBConnection( mySession ); if ( conn == null ) { return false; } Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); //组合SQL语句 StringBuffer sQuery = new StringBuffer(); sQuery.append( "select * from resume where 1=1 "); if ( sResumeId1 != null && !sResumeId1.equals("") ) { sQuery.append( "and resume_id>='" sResumeId1 "' "); } if ( sResumeId2 != null && !sResumeId2.equals("") ) { sQuery.append( "and resume_id<='" sResumeId2 "' "); } if ( sRealname != null && !sRealname.equals("") ) { sQuery.append( "and realname like '%" sRealname "%' "); } if ( sSex != null && !sSex.equals("") ) { sQuery.append( "and sex='" sSex "' "); } if ( sMaxEducation != null && !sMaxEducation.equals("") ) { sQuery.append( "and max_education like '%" sMaxEducation "%' "); } if ( sMajor != null && !sMajor.equals("") ) { sQuery.append( "and major like '%" sMajor "%' "); } if ( sCurrentJobType != null && !sCurrentJobType.equals("") ) { sQuery.append( "and current_job_type like '%" sCurrentJobType "%' "); } if ( sCurrentCity != null && !sCurrentCity.equals("") ) { sQuery.append( "and current_city like '%" sCurrentCity "%' "); } sQuery.append("order by resume_id desc"); //执行SQL语句 rs = stmt.executeQuery( sQuery.toString() ); Vector processResumes = new Vector(); //循环取得所有检索到的简历 while ( rs.next() ) { ResumeContent resumeObj = new ResumeContent(); resumeObj.setResumeId( rs.getString("resume_id") ); resumeObj.setRealname( rs.getString("realname") ); resumeObj.setSex( rs.getString("sex") ); resumeObj.setBornDate( rs.getString("born_date") ); resumeObj.setMaxEducation( rs.getString("max_education") ); resumeObj.setMajor( rs.getString("major") ); resumeObj.setEmail( rs.getString("email") ); resumeObj.setContactPhone( rs.getString("contact_phone") ); resumeObj.setMobile( rs.getString("mobile") ); resumeObj.setCurrentJobType( rs.getString("current_job_type") ); resumeObj.setExpectJobType( rs.getString("expect_job_type") ); resumeObj.setCurrentPosition( rs.getString("current_position") ); resumeObj.setExpectPosition( rs.getString("expect_position") ); resumeObj.setCurrentCity( rs.getString("current_city") ); resumeObj.setExpectCity( rs.getString("expect_city") ); resumeObj.setExpectSalary( rs.getString("expect_salary") ); resumeObj.setResumeContent( rs.getString("resume_content") ); resumeObj.setExpireTime( rs.getString("expire_time") ); processResumes.add( resumeObj ); } //如果一条也没有查找出来 if ( processResumes.size() == 0 ) { mySession.setAttribute("errMsg","共查找到0条记录,请重新指定查询条件。"); return false; } //放入页面值域 myValues.put( "resumes", processResumes ); //计算总页数 int countPerPage = ((Integer)mySession.getAttribute( "countPerPage" )).intValue(); int totalResumes = processResumes.size(); int totalPage = 0; if ( totalResumes % countPerPage == 0 ) { totalPage = totalResumes/countPerPage; } else { totalPage = totalResumes/countPerPage 1; } int curPage = 0; //放入当前页码 myValues.put( "curPage", new Integer(curPage) ); //放入总页码 myValues.put( "totalPage", new Integer(totalPage) ); return true; } catch(Exception e) { e.printStackTrace(); mySession.setAttribute("errMsg","在数据库中查找简历的时候出现错误,请联系技术人员!"); return false; } finally { try { rs.close(); stmt.close(); conn.close(); }catch(Exception ex) { } } } }
好例子网口号:伸出你的我的手 — 分享!
网友评论
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
支持(0) 盖楼(回复)