日期:2014-05-17 浏览次数:20791 次
<% String dbDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL="jdbc:sqlserver://localhost:1433;databaseName=classroom;user=sa;password=19881206"; Connection conn = null; Statement stmt= null; String sql = null; ResultSet rs = null; String str=request.getParameter("CRno"); try{ Class.forName(dbDriver); conn=DriverManager.getConnection(dbURL); stmt=conn.createStatement(); sql="SELECT CRno,Capacity FROM classroom where classroom.CRno='"+str+"'"; rs=stmt.executeQuery(sql); %> <center> <table border=2> <caption>教室信息</caption> <tr> <th>教室编号</th><th>教室容量</th> </tr> <%while(rs.next()){ %> <tr> <td><%=rs.getString("CRno")%></td> <td><%=rs.getString("Capacity")%></td> </tr> <%} conn.close(); } catch(SQLException e) {System.out.println(e); } %>
<% String dbDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL="jdbc:sqlserver://localhost:1433;databaseName=classroom;user=sa;password=19881206"; Connection conn = null; Statement stmt= null; String sql = null; ResultSet rs=null; String str; str=request.getParameter("Tname"); try{ Class.forName(dbDriver); conn=DriverManager.getConnection(dbURL); stmt=conn.createStatement(); sql="select Tname,Deptname,Ttitle,Cname,CRno,Weekday,Period from teacher,teach_course,course,dept where teacher.Tno=teach_course.Tno and teacher.Deptno=dept.Deptno and teach_course.Cno=course.Cno and teacher.Tname='"+str+"'"; rs=stmt.executeQuery(sql); %> <center> <table border=2> <caption>教师开课信息</caption> <tr><th>教师姓名</th><th>所属院系</th><th>职称</th><th>课程名</th><th>上课地点<th>上课时间</th><th>节次</th> </tr> <%while(rs.next()) {%> <tr> <td><%=rs.getString("Tname")%></td> <td><%=rs.getString("Deptname")%></td> <td><%=rs.getString("Ttitle")%></td> <td><%=rs.getString("Cname")%></td> <td><%=rs.getString("CRno")%></td> <td><%=rs.getString("Weekday")%></td> <td><%=rs.getString("Period")%></td> </tr> <%} conn.close(); }catch(SQLException e) { System.out.println(e); } %>