下载Microsoft  SQL  Server  2000  Service  Pack  3a并安装,SQL请选用混和安装模式!!!  

解决方案 »

  1.   

    你sqlserver服务运行了吗?也可能是这个原因
      

  2.   

    SQLSERVER没有运行或是运行失败,重新打补丁~~~
      

  3.   

    我用的也是SQLServer2000,程序对的sqlServer装成混合模式,补订也要装成混合模式
      

  4.   

    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page import="java.sql.*"%>
    <html>
    <body><%
      try{
      Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
      String url="jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=pubs";
      String user="sa";
      String password="19801231";
      Connection conn = DriverManager.getConnection(url,user,password);
        PreparedStatement stmt = conn.prepareStatement("select * from test");
        ResultSet rs = stmt.executeQuery();
        
        while(rs.next()){
          
          %>
          您的第一个字段内容为:<%=rs.getString(1)%>
          您的第二个字段内容为:<%=rs.getString(2)%>
          <%}
          }catch(Exception ex){
            System.out.println("没有表");
          }
    %>
    <%out.print("数据库操作成功,祝贺您");%></body>
    </html>
    1确定PUBS有表,2确定数据库密码 ,3没有try{}catch(Exception ex){}
      

  5.   

    感觉这样写jsp有点宝气,你的class.forName后面不需要newInstance了
    执行数据库操作需要try catch起来。
    还有,不要在jsp页面中出现java代码,也就是避免<%%><%=%>的出现。
    不要在jsp页面中连接数据库,jsp是用来做显示的,非要连接建议用sql标签来实现。