日期:2014-05-17  浏览次数:20931 次

急!,jsp连接SQL Server2008失败,求大神看看
以下是我的代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>通过JDBC驱动访问SQLSever 2008</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
    <center>
      <br/><br/><br/>
      <h2>使用JDBC驱动访问 SQL Server 2008数据库</h2>
      <hr/>
      <table border=2 bgcolor="ccceee" align="center">
           <tr>
              <th>学号</th>
              <th>姓名</th>
              <th>性别</th>
              <th>年龄</th>
              <th>体重</th>
           </tr>
        <%
           Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
           String url = "jdbc:sqlserver://localhost:1433;databasename=student";
           String user = "sa";
           String password="root";
           Connection conn=DriverManager.getConnection(url,user,password);
           Statement stmt = conn.createStatement();
           String sql = "select * from info";
           ResultSet rs = stmt.executeQuery(sql);
           while(rs.next()){
         %>
         <tr>
           <td><%=rs.getString("studentNumber") %>