我的源代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <%@ page import="com.microsoft.*"%>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>JSP_SQL</title> </head>
<body> <marquee onmouseover="this.stop()" onmouseout="this.start()" direction="up" scrollamount="1" scrolldelay="1" height="117"> <h1>Connect SQLserver</h1> <%out.print("<h3>This is an example!我做的试验!!!</h3>");%> </marquee> <table border=1> <tr> <td>姓名</td> <td>年龄</td> <td>地址</td> </tr> <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=;DatabaseName=web"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from renwu"); while(rs.next()) { %> <tr> <td><%=rs.getString("name")%></td> <td><%=rs.getString("age")%></td> <td><%=rs.getString("adress")%></td> </tr> <% } rs.close(); con.close(); %> </table> </body> </html>
不知道究竟是什么原因?不能显示出表中的内容,请高手指点,谢谢!!1