stu1.jsp~8~
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- <%@page contentType="text/html;charset=gb2312"%>
- <%@page import="java.sql.*"%>
- <HTML>
- <head><SCRIPT language="JavaScript">
- function a() {
- if(form1.username.value==""){
- alert("用户名不能为空,请确定后重新输入");
- form1.username.focus();
- return false;
- }
- return true;
- }</script>
- </head>
- <BODY ><br><br><br><br>
- <%
- Connection conn = null;
- Statement stmt = null;
- ResultSet rs = null;
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- }
- catch(ClassNotFoundException ce){
- out.println(ce.getMessage());
- }
- request.setCharacterEncoding("GBK");
- String str = request.getParameter("keywords");
- if( str == null)
- str = "";
- else
- try{
- conn=DriverManager.getConnection("jdbc:odbc:dsn112");
- stmt=conn.createStatement();
- rs=stmt.executeQuery("SELECT * FROM stu WHERE name LIKE '%" + str + "%'");
- out.print("<TABLE align='center' width='70%' BORDER='0'>");
- out.print("<tr bgcolor='EcEcff' align='center'><TD>学期号</TD>");
- out.print("<TD>课程号</TD>");
- out.print("<TD>课程名</TD>");
- out.print("<TD>学分</TD>");
- out.print("<TD>成绩</TD>");
- out.print("<TD>重修成绩</TD>");
- out.print("<TD>主讲老师</TD></TR>");
- while(rs.next()){
- out.print("<tr bgcolor='FFEFEF' align='center'><TD>"+rs.getString("xq_id")+"</TD>");
- out.print("<TD>"+rs.getString("co_id")+"</TD>");
- out.print("<TD>"+rs.getString("co_name")+"</TD>");
- out.print("<TD>"+rs.getString("credit_hour")+"</TD>");
- out.print("<TD>"+rs.getString("cj")+"</TD>");
- out.print("<TD>"+rs.getString("cxcj")+"</TD>");
- out.print("<TD>"+rs.getString("teacher")+"</TD></TR>");
- }
- out.print("</TABLE>");
- }
- catch(SQLException e){
- System.out.println(e.getMessage());
- }
- finally{
- stmt.close();
- conn.close();
- }
- %>
- <br><br>
- <br><br>
- <FORM Action="" Method="POST">
- <table width="70%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#A5C1CC">
- <tr bgcolor="#fcd56c">
- <td height="40" colspan="2"><div align="center" ><font size="5" color="#000000"><strong>查找信息</strong></font></div></td>
- </tr>
- <tr ><td><font color="000000" size="4">输入姓名关键字:</td>
- <td><INPUT Type="Text" Name="keywords" Value="<%=str%>"></td></tr>
- <tr bgcolor="#fcd56c"><td height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找"></td></tr></table>
- </FORM>
- </BODY></HTML>