jsp连接SQL sever 2000时出现了“[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket”!求救!

hhgg123 2007-05-02 10:34:47
1:我的SQL sever 2000也装了,身份验证模式是“windows 和SQL sever 混合身份验证模式”,密码是"sa".
2:sp3 补丁也打了,在C盘根下解压成一个”sql2ksp3“文件夹。
3:jdbc驱动也安了,并并将lib里的三个.jar文件也放在了系统变量里了。
4:在SQL sever 2000里建了一个数据库,名字是“university",在里又建了一张表,是“student",又新建了一个"用户登陆",用户名是"admin",密码是"123456"

我写了一个测试是否连上数据库的例子,名字是DataCon.jsp,代码如下:

<%@ page contentType="text/html;charset=GB2312" language="java" import="java.sql.*;" errorPage="" %>
<html>
<head>
<title>Student Info Manage System</title>
</head>
<%! String url,sql; %>
<%! Connection conn; %>
<%! ResultSet rs; %>
<%! Statement stmt; %>
<%! int i; %>
<body bgcolor="#ffffff">
<div align="center"><font color="#000000" size="5">Student Info Manage System</font></div>
<table width="75%" border="1" cellspacing="1" cellpadding="1" align="center">

<%

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=university";
System.out.println("successfuylly");
conn=DriverManager.getConnection(url,"sa","sa");
stmt=conn.createStatement();
sql="select * from student";
rs=stmt.executeQuery(sql);



%>
</table>

</body>
</html>
...全文
1448 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
vansention 2007-05-02
  • 打赏
  • 举报
回复
同上,我昨天也遇到这个问题,现在解决了
hbyu2005 2007-05-02
  • 打赏
  • 举报
回复
楼上说得对,你的sp3只是解压缩,还没有安装,打开文件夹,运行setup,安装补丁,安装完后,1433的端口才能打开。
CrazyGou 2007-05-02
  • 打赏
  • 举报
回复
打开这个文件夹,运行setup
hhgg123 2007-05-02
  • 打赏
  • 举报
回复
sp3补丁我已经打了,已经在c盘根目录下生成一个”sql2ksp3要“的文件夹了呀!不是这个原因吧!
jk88811 2007-05-02
  • 打赏
  • 举报
回复
SQL Server 2000 的 SP3 或 SP4 补丁

自己上网搜一个打一下就可以了...
hhgg123 2007-05-02
  • 打赏
  • 举报
回复
可是报错如下:
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]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.DataCon_jsp._jspService(DataCon_jsp.java:90)
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]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(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:523)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.DataCon_jsp._jspService(DataCon_jsp.java:72)
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.

我觉得自己该安的都安了呀,怎么还是不好使呢?真是闹心啊!
lc328 2007-05-02
  • 打赏
  • 举报
回复
没开1433端口,,,打补丁。SP3以上~

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧