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.mi