注册 登录
编程论坛 J2EE论坛

连接sqlserver2000有问题!大虾看看

fengxfu 发布于 2007-02-01 13:27, 1858 次点击

连接sqlserver2000有问题!大虾看看~~~
tomcat提示如下:



HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

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]Error establishing socket.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.sqlserver.index_jsp._jspService(index_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
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(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.sqlserver.index_jsp._jspService(index_jsp.java:53)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

20 回复
#2
fengxfu2007-02-01 13:28

急等大虾回复!先谢过了.

#3
支离破碎2007-02-01 13:47
网上找的解决方法:
1、下载Microsoft SQL Server 2000 Service Pack 3a并安装,SQL请选用混和安装模式!!!
http://www.microsoft.com/downloads/details.aspx?FamilyId=90DCD52C-0488-4E46-AFBF-ACACE5369FA3&displaylang=zh-cn

2、下载SQL Server 2000 Driver for JDBC Service Pack 3
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en



或:
Resolution: do one of the following:

Increase the port range that is used for anonymous ports to approximately 20,000 ports (for example) by modifying the MaxUserPort registry key (this parameter controls the maximum port number that is used when an application requests any available user port from the system). Windows uses the conventional BSD range of 1024 to 5000 for its anonymous (ephemeral) port range. You can set only the upper bound of the ephemeral port range. To modify the MaxUserPort registry key, follow these steps:
Start Registry Editor (Regedt32.exe). Please note that you should backup your registry and any important files on your computer before editing the registry.
Locate the MaxUserPort key in the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
On the Edit menu, click Add Value, and then add the following registry value:
Value Name: MaxUserPort
Data Type: REG_DWORD
Value: 65534 (for example)
Valid Range: 5000-65534 (decimal)
Default: 0x1388 (5000 decimal)
Quit Registry Editor.
Change the timeout on the connections from 240 seconds (the default) to any length from 30 seconds to 300 seconds. Use the TcpTimedWaitDelay registry parameter to change this value. To do this, start Registry Editor (Regedt32.exe), locate the following key in the registry, and then modify the value HKEY_LOCAL_MACHINE\System\CurrectControlSet\services\Tcpip\Parameters (this parameter determines the length of time that a connection stays in the TIME_WAIT state when the connection is being closed. While a connection is in the TIME_WAIT state, the socket pair cannot be reused. For more information, see RFC 793):
Value Name:TcpTimedWaitDelay
Value Type: REG_DWORD-time in seconds
Valid Range: 30-300 (decimal)
Default: 0xF0 (240 decimal)
More information available at http://support.microsoft.com/default.aspx?scid=kb;EN-US;319502 .
#4
风月_无边2007-02-01 14:52
应该是和驱动有关的
#5
angeloc2007-02-01 17:13
是需要打补丁
#6
liuliulc2007-02-01 20:23
应该是没有加载JDBC的三个.JAR文件..
#7
fengxfu2007-02-02 15:39
谢!
#8
fengxfu2007-02-02 15:49
#9
lgdcky2007-02-02 22:37
??接口错误!可能是驱动问题吧!
#10
fqj7932007-02-03 10:06

我也是遇到这个问题,三个驱动文件复制过去了,而且是以前是可以的,后来就不行了,而且我用的全部一样的方法重做了也还是这个提示.闷!

#11
lgdcky2007-02-03 10:22
用驱动桥连接的话包里该有的吧!你试试用sun.jdbc.odbc.JdbcOdbcDriver连了看看!还有楼主能把你的代码贴出来吗?

[此贴子已经被作者于2007-2-3 10:25:22编辑过]


#12
fqj7932007-02-03 10:50

<html>
<head>
<title>使用JSP访问Sql Server7.0/2000数据库 </title>
</head>
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<body>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from mytable";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%
}%>
<%out.print("数据库操作成功,恭喜你");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

这是我的代码!

#13
fqj7932007-02-03 11:07
sun.jdbc.odbc.JdbcOdbcDriver这个可以连接ACCESS数据库!
#14
fengxfu2007-02-05 15:05
想哭~~~


谢谢各位的帮助!  前天我刚把电脑丢了。伤心啊,上面有我以前的所有资料和作品!

#15
fqj7932007-02-05 17:01

这么不小心呀!

#16
fqj7932007-02-05 17:01
同情!
#17
smoon2007-02-05 17:21

不是吧。。放假拉都 怎么把电脑给。。。。

#18
lilin1232007-02-28 22:06
作数据库连接推荐使用连接池,直接可以测试是否有问题
#19
yangtaolive2007-03-03 11:52
可不可以帮我 搞一下 动态加载的 问题
联系QQ: 31977100
#20
yudiao1232007-03-05 20:43
回复:(fengxfu)想哭~~~谢谢各位的帮助!  前天...

不会吧!可怜中!!!

#21
fqj7932007-03-07 11:35

我的这个问题还是没有解决,不知还有没有其他的方法可以试试?

1