JSP连接SQL2000出现的问题,求高人指点
我的JSP环境是J2SDK1.4.2+tomcat5.0.28,数据库SQL2000在局域网内服务器上
服务器地址10。1。15。30,操作系统windows xp professsional jsp代码如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%!
public static String getGBString(String src) {
try {
return new String(src.getBytes("ISO-8859-1"), "gb2312");
} catch (java.io.UnsupportedEncodingException e) {
return null;
}
}
%>
<html>
<body>
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://10.1.15.30:1433;DatabaseName=Jztest";
//test你的数据库的
String user="zhaosx";
String password="aaasss";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=getGBString(rs.getString(1))%> <br>
您的第二个字段内容为:<%=getGBString(rs.getString(2))%> <br>
<%}%>
<%out.print("数据库操作成功,恭喜你");%> <br>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
运行出现以下情况:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]用户 'zhaosx' 登录失败。原因: 未与信任 SQL Server 连接相关联。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.t4_jsp._jspService(t4_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]用户 'zhaosx' 登录失败。原因: 未与信任 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(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.t4_jsp._jspService(t4_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
[解决办法]
看看你设置的是不是仅WINDOWS登陆
[解决办法]
用客户端用户名'zhaosx'登陆看看,如果能够登陆的了
可能是没装sp3补丁吧
[解决办法]
1、数据库不要用windows帐户登陆,数据库设置成混合模式登陆,专门建立一个帐户用来连接,
2、装SP3补丁
3、网络是否连通,数据库是否运行
4、以上三点做到,还是不通,RPWT,请检查前三条
[解决办法]
你用zhaos在查询分析起中登录试试能不能登录上啊
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html