《java简单图书馆管理系统.docx》由会员分享,可在线阅读,更多相关《java简单图书馆管理系统.docx(23页珍藏版)》请在第壹文秘上搜索。
1、publicStringgetNutnber(returnnumber;)publicvoidsetName(Stringname)this.name三name;)publicStringgetNacne()returnname;)publicvoidSetAuthor(Stringauthor)1this.author-author;)publicStringgetAthor(I(returnauthor;)publicvoidSetChubanshe(Stringchbanshe(this.Chubanshe-ChUbaCshe;)publicStringgetChubanshe0retu
2、rncbanshe;)publicvoidSetJiage(Stringjiage(this.jiage三jiage;JpublicStringgetJiageOreturnjiage;)publicvoidSetShuliang(Stringshuliang)this.Shu1.iang三shuliang;)publicStringgetshuliang()returnshuliang;)Userlogii1.jsp登陆界面Utilr*p9eEnc0dingr9UTF-8,i1I.PUB1.IC,-W3CDTDHTM1.4.01TM11SitionalENwfifift!-forr.name
3、三rrfor11wmethod=PoStrTaction三Iogin,登录管理界i管理员账号vtd6nb3p;nbs;4nbs;(nbs;4nbs;nbs;User1.ogin/servlet用户登录的处卉packagelibrary.database;importjav.io.IOCxception;importjava.servlet.RequestDispatcher;importjavaservlet.ServletException;importjavax.servlet.Servlet;importjava.servlet.ServletRequest;importjava.ser
4、vlet.ServletResponse;importlibrary.info.*;publicclassUser1.oginextendsServlet(privatestaticfinallongserialVersionyiD-11.;publicvoiddestroy()(super.destroy(;IlJustputsdestroy0stringinlog/Putyourcodehere)publicvoiddoGet(ServletRequestrequest,ServletResponseresponse)throwsServletException,IOExceptiondo
5、Post(request/response);)publicvoiddoPostServletRequestrequest,ServletResponseresponse)throwsServletEcetionrIOExceptionStringurlerror.jap*;response.SetContentType(teChtml);response.SetCharacterEncoding(,UTF-8);request.SetCharacterEncoding1.UTF-8);Adminuser-newAdmin();user.SetUsername(request.getParat
6、reter(,sername,).trim();user.setuserkey.trim11;if(user.getUsername().equals()Iluser.getUserkey(.equals(*t)(request.SetAttribute1.mWSSage用户Z或密码不能为空,请IK新输入!;IseifA4minDatabase.Check1.ogin(user)三三3)irl=index.jspn;request.SetAttributeusernarre,user.getUsername();Jelseif(AdminDatabase.Check1.ogin(user)=三
7、2)irequest.SetAttribute(message,”密码有误,iitft!w);elseif(AdminDatabase.Check1.ogin(userI-1)throwsServletException(/PutyourcodehereAdninDatabase处理登陆的数据库信息packagelibrary.database;importjava.aql.Connection;importjava.aql.DriverManager;importjav.sql.SQ1.Exception;importjava.sql.ResultSet;importjava.aql.Sta
8、tement;importlibrary.info.;publicclassAdminDatabase(publicstaticConnectiongetconnect(StringDBDRIVER-Com.microsoft.sqlserver.jdbe.SQ1.ServerDriverw;StringDBUR1.=jdbc:sqlserver:/localhost:1433;databaseName=libraryinfoM;Connectioncon一null;try(Class.forNaw(DBDRIVER);con=DriverManager.getConnection(DBUR1
9、.rsazty,);catch(ClassNotFoundExceptione)(System,err.printIn(e.gett4essage)I;System.exit);catch(SQ1.Exceptione)(System,err.printIn(e.gett4essage);Jreturncon;)publicstaticintCheck1.ogin(Adminuser)Admintemp三newAdmin();Connectioncon=nll;Statementstmt-null;ResultSetrs-null;booleanflag-false;intlab-1;try(
10、Con=AdminDatabase.getconnect();stmt-con.CreateStatementO;rs-stmt.GxecuteQueryselectfroma(flag三true;temp.setusername(rs.getString(sername*).trim();temp.setuserkey.irim();if(user.equals(temp)Iaba3;flag-false;break;)if(flag)lab-2;catch(SQ1.Exceptione)1System.err.printIn(e.getMessage();(ifUs!-null)tryfr$.closed;catch(SQ1.Exceptione)IFinai2ycon,stmt);returnlab;)publicstaticvoidFinallyConnectionconrStatetrientstmtIFifJtry(con.close();Jcatch(SQ1.Exceptione)1error,jsp处理错误信息pagelanguage-njavat9import-*java.utii.pageEncodlng-nUTF,-8,:,-W3CTDHTM1.4.01TransitionalEN,basehref-r,n