<% @ page contentType = " text/html; charset=gb2312 " language = " java " import = " java.sql.*,java.io.* " %> < html > < body > 以下是从Ms SQL Server2000数据库读取的数据: < hr > < table border = 1 > < tr >< td > 图书ID </ td >< td > 书 名 </ td >< td > 出版社 </ td >< td > 价 格 </ td ></ tr > <% Class.forName( " sun.jdbc.odbc.JdbcOdbcDriver " ); Connection con = DriverManager.getConnection( " jdbc:odbc:books " , " sa " , "" ) ; Statement stmt = con.createStatement(); ResultSet rst = stmt.executeQuery( " select * from book " ); while (rst.next()) ... { out.println("<tr>"); out.println("<td>"+rst.getString("bookId")+"</td>"); out.println("<td>"+rst.getString("bookName")+"</td>"); out.println("<td>"+rst.getString("publisher")+"</td>"); out.println("<td>"+rst.getFloat("price")+"</td>"); out.println("</tr>"); } // 关闭连接、释放资源 rst.close(); stmt.close(); con.close(); %> </ table > </ body > </ html >