本人使用dreamweaver+tomcat+sqlserver2000(sp4),不知道为什么,无法连接上数据库??
环境变量:CATALINA_HOME:C:\Program Files\Apache Software Foundation\Tomcat 5.5
          CLASSPATH:.;C:\Program Files\Java\jdk1.5.0_15\lib\dt.jar;C:\Program Files\Java\jdk1.5.0_15\lib\tools.jar
         JAVA_HOME:C:\Program Files\Java\jdk1.5.0_15
         Path:C:\Program Files\Java\jdk1.5.0_15\bin;F:\Delphi\Bin;F:\Delphi\Projects\Bpl\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;%java_home%\bin;%java_home%\jre\bin;%tomcat_home%\bin;
         TOMCAT_HOME:C:\Program Files\Apache Software Foundation\Tomcat 5.5源程序:<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<jsp:directive.page import="java.lang.Class"/>
<jsp:directive.page import="java.sql.DriverManager"/>
<jsp:directive.page import="java.sql.Connection"/>
<jsp:directive.page import="java.sql.Statement"/>
<jsp:directive.page import="java.sql.ResultSet"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>SQL Server 2000</title>
  </head>
  
<body topmargin="0">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="11%"></td>
    <td width="78%"></td>
    <td width="11%"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td bgcolor="#CCFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><font size="3"><b>在JSP中连接SQL Server 2000数据库</b></font></td>
      </tr>
      <%
      String driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver";
      String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=db_JSDQ10";
      String username = "sa";
      String password = "";
      Class.forName(driverClass);
      Connection conn=DriverManager.getConnection(url, username, password);
      Statement stmt=conn.createStatement();
      ResultSet rs = stmt.executeQuery("select * from tb_test_join");
      %>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><table width="30%" bordercolor="#00CC66"  border="1" cellspacing="0" cellpadding="4">
          <tr align="center" bgcolor="#FF6633">
            <td>编号</td>
            <td>姓名</td>
          </tr>
          <%
          while(rs.next()){
           out.println("<tr align='center' bgcolor='#FFCC99'>");
           for(int i=1;i<3;i++){
               out.println("<td>"+rs.getObject(i)+"</td>");
           }
           out.println("</tr>");
          }
          %>
        </table></td>
      </tr>
      <%
      rs.close();
      stmt.close();
      conn.close();
      %>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
错误:type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.index_jsp._jspService(index_jsp.java:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]用户 'sa' 登录失败。原因: 未与信任 SQL Server 连接相关联。
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]An error occured while attempting to log onto the database.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.

解决方案 »

  1.   

    问题一般是由于SQL Server未集成Windows身份验证导致的,所以解决方案为:1 打开SQL Server企业管理器。
    2 选择服务器名称上右键选择“编辑SQL Server注册属性”,然后在对话框中选择“使用windows身份验证”。
    3 试一试,不行。在看看安全性设置
    4 同样右键,选择“属性”,然后打开“安全性”选项卡。
    5 在选项卡中,选择身份验证为“SQL Server和 Windows ”,其他不变
      

  2.   

    SQLServer 2000 Driver for JDBC  能找到驱动包不。。 
      

  3.   

    http://topic.csdn.net/u/20080405/06/fc8e48d0-b84c-4642-88f0-390a9295a27e.html?1698261955
      

  4.   

    问题一般是由于SQL Server未集成Windows身份验证导致的,所以解决方案为: 1 打开SQL Server企业管理器。 
    2 选择服务器名称上右键选择“编辑SQL Server注册属性”,然后在对话框中选择“使用windows身份验证”。 
    3 试一试,不行。在看看安全性设置 
    4 同样右键,选择“属性”,然后打开“安全性”选项卡。 
    5 在选项卡中,选择身份验证为“SQL Server和 Windows ”,其他不变 回复:这就是问题的关键,再次感谢你!