[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.1、winXP sp2系统安装SQL Server2000标准版;2、混合认证模式;2、已安装SQL Server2000 sp3;3、已安装JDBC SP3;4、查看SQL Server服务器和客户机默认端口均为1433;5、命令窗口中使用telnet 1433命令,错误如下:
正在连接到localhost:1433...不能打开到主机的连接, 在端口 23: 连接失败;程序如下:public class test { public static void main(String[] args) throws ClassNotFoundException {
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName =test";
Class.forName(driver);
System.out.println("Driver is OK");//输出正常
try {
Connection conn = DriverManager.getConnection(url,"sa","sa");//错误
System.out.println("Connect to DBMS is OK!");
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
正在连接到localhost:1433...不能打开到主机的连接, 在端口 23: 连接失败;程序如下:public class test { public static void main(String[] args) throws ClassNotFoundException {
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName =test";
Class.forName(driver);
System.out.println("Driver is OK");//输出正常
try {
Connection conn = DriverManager.getConnection(url,"sa","sa");//错误
System.out.println("Connect to DBMS is OK!");
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
解决方案 »
- 平台中使用ExecutorService,CompletionService中的线程停止的问题
- jsp中判断的问题
- 连接SQLServer2000中的datetime问题
- JSP中实现Ctrl+F查找
- 页面中的某个按钮失效了但在别的机子可以使用,在线求解??
- oracle bfile 字段操作
- 使用new String(yourStr.getBytes("big5"),"GB2312")无法将繁体转换成简体
- JavaWebStudio是国产的吗 免费吗?
- 关于数据库语句把asp转成jsp的问题
- 对于“动态 Form” 大家有什么高见? 望不吝赐教
- 用itext写pdf,怎样使写入的文字居中呢?
- java.lang.IncompatibleClassChangeError (如能正确,送100分)
Symptom: while running a windows application that includes massive opening and closing of a connections to database server, "Error establishing socket" exception appears after a short time of execution.Cause: This problem is caused by a lack of a reusable sockets on client machine, since each TCP/IP connection stays in the TIME_WAIT state when the connection is being closed. While a connection is in this state, the socket cannot be reused.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
3个JDBC包没打进去?
二步:按装数据源sp3驱动,
三步,将数据源驱动下的msbase,mssqlserver,msutil这三个文件拷到你的工程文件下
四:ok
命令窗口中使用telnet 1433命令,错误如下:
正在连接到localhost:1433...不能打开到主机的连接, 在端口 23: 连接失败;
这个怎么解决???
1、 服务器正常启动检查是不是使用1433 端口
2、查看防火墙是不是屏蔽1433端口了
3、CMD-NETSTAT -AN 检查下你的1433端口是不是开启 没有的话 打SQL SERVER 的补丁 SP3 OR SP4 基本都是补丁问题
LZ可以揭贴了。
1.如果你是win2003,那么一定要安装sql的补丁sp3a检查你的SQL有没有打补丁,没有的话要打上补丁,检查的方法是在查询分析器中运行:
select @@version
如果出来的版本号是8.00.760以下,则表明你未安装sp3的补丁,要装上.详细请看:http://www.i170.com/user/power/Article_24904
谢谢 jhy2003hn