〈/html〉
5.3读者管理档案模块
图5—3读者档案管理模块
读者档案管理模块相关代码:
<%
Class。
forName(”sun。
jdbc.odbc.JdbcOdbcDriver");
Connectioncon=DriverManager.getConnection(”jdbc:
odbc:
zc",”sa","111111");
Statementstmt=con。
createStatement();
ResultSetrs;
rs=stmt。
executeQuery(”select*fromreader");
%>
〈tr〉
〈tdheight="510”valign=”top"style=”padding:
5px;">〈tablewidth=”98%"height=”487"border=”0"cellpadding=”0"cellspacing="0">
〈tr〉
〈tdheight="22"valign="top"class=”word_orange”>当前位置:
〈tr〉
〈tdalign=”center”valign="top"〉 〈tablewidth=”100%"border=”0”cellspacing="0"cellpadding="0”〉 〈tr〉 〈tdwidth=”25%"> 〈ahref=”reader_add.jsp”class="STYLE3">添加读者信息 〈/tr〉 〈tablewidth="98%”border="1"cellpadding="0"cellspacing="0"bordercolor=”#FFFFFF"bordercolordark="#D2E3E6”bordercolorlight=”#FFFFFF"> 〈tdwidth="8%">性别〈/td> 〈tdwidth="12%"〉班级〈/td> 〈tdwidth=”20%">院系〈/td> 〈/tr> 〈% while(rs.next()){ out.println(” out。 println(" (1)+” out.println(" getString (2)+”〈/td>"); out.println(" out.println(” getString(4)+”〈/td>”); out.println(" getString(5)+" } %〉 〈/table〉 〈/td> 5。 4读者添加模块 图5-4读者添加模块 读者添加模块核心代码: 〈% Class。 forName("sun.jdbc。 odbc。 JdbcOdbcDriver"); Connectioncon=DriverManager.getConnection(”jdbc: odbc: zc”,”sa”,”111111"); Statementstmt=con。 createStatement(); ResultSetrs; rs=stmt.executeQuery("select*fromreader”); %〉 <% try{ Stringid=request.getParameter("id”); if(id==null) {id="";} Stringname=request.getParameter("name”); if(name==null) {name="";} Stringsex=request.getParameter("sex"); if(sex==null) {sex=””;} Stringbanji=request。 getParameter(”banji"); if(banji==null) {banji=”";} Stringdept=request。 getParameter(”dept”); if(dept==null) {dept="”;} try{bytea[]=name。 getBytes(”ISO—8859—1”); name=newString(a,”gb2312”); byteb[]=sex.getBytes("ISO—8859-1"); sex=newString(b,"gb2312”); bytec[]=dept.getBytes(”ISO-8859-1"); dept=newString(c,”gb2312");} catch(Exceptione){} if(id! =null&&name! =null&&sex! =null&&banji! =null&&dept! =null){ Stringstr1= ”INSERTINTOreaderValues"+”(”+"'”+id+"’,’”+name+"','"+sex+”',’"+banji+"','"+dept+"')"; stmt.executeUpdate(str1);} rs。 close(); stmt.close(); con。 close();} catch(Exceptione){ out.println(” out。 println(””); out。 println(”〈/b>〈/font>”); }%〉 〈% Class.forName(”sun.jdbc.odbc。 JdbcOdbcDriver"); rs=stmt.executeQuery("select*fromreader"); %> 5。 5读者信息查询模块 图5-5读者信息查询模块 读者信息查询代码: 〈formaction="chaxunjieguo。 jsp”method="get”〉 〈spanclass="STYLE1">读者查询页面 〈br〉 〈inputtype=”radio”name="selectetype”value=”按性别查询"/>性别查询 〈/label> 〈label> 〈inputtype=”radio”name=”selectetype"value="按班级查询"/>按班级查询 〈inputtype="text”name=”selecteinfo"/〉 〈/label> 核心代码: 〈%Stringselectetype=request.getParameter(”selectetype”); Stringselecteinfo=request.getParameter("selecteinfo”); if(selectetype! =null&&selecteinfo! =null){ Class.forName("sun。 jdbc.odbc.JdbcOdbcDriver”); Connectioncon=DriverManager.getConnection(”jdbc: odbc: zc”,"sa”,”111111"); Statementsta=con。 createStatement(); Stringsql1="select*fromreaderwhere性别=’”+selecteinfo+”’"; ResultSetrs1=sta.executeQuery(sql1); Stringuserid=”按性别查询”; Stringusername=”按班级查询"; if((userid.trim()).equals(selectetype.trim())){ %> 〈tdwidth=”10%"〉姓名〈/td> 〈tdwidth="8%”〉性别〈/td〉 〈tdwidth=”12%”>班级 <%while(rs1.next()){ out.print(" out。 print("〈td>”+rs1。 getString (1)+”〈/td>”); out。 print(" (2)+” out.print("〈td>"+rs1。 getSt copyright@ 2008-2022 冰豆网网站版权所有 经营许可证编号:鄂ICP备2022015515号-1 ");”+rs.getString(3)+" ”);”+rs。 ”+rs。