博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL Server JDBC Connection Errors: Error establishing socket, connection refused...
阅读量:4050 次
发布时间:2019-05-25

本文共 4371 字,大约阅读时间需要 14 分钟。

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.        at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)        at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)        at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)        at com.microsoft.jdbc.sqlserver.tds.TDSConnection.(Unknown Source)        at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)        at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)        at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)        at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)SQL server 2005 JDBC Driver:com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed.                                      java.net.ConnectionException: Connection refused: connect        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)        at com.microsoft.sqlserver.jdbc.SQLServerException.connect(Unknown Source)        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)

For this kind of database connection problem, there are always two distinct issues:

  1. The SQL server itself is not running or TCP/IP is disabled. That can be confirmed by run

    netstat

    and see it is listed there. And then run

    telnet localhost 1433

    and see it can connect (or whatever port number).

  2. Even if the server is running, a client program such like jdbc may still fail to connect to it because of a

    firewall

    For testing, you can turn off the XP firewall. And if you have other firewall running, check the firewall log and see any activities that might be related.

You can also verify whether or not your server is running from the

 

  • SQL Server Network Utility

    on the server, or from another client utility such as

    SQL Query Analyzer

    or a command line utility such as

    osql

     

To check the enabled protocols for a server, follow these steps:

  1. In SQL Server 2000, start the SQL Server Network Utility (svrnetcn.exe).
  2. On the General tab, select the instance of Microsoft SQL Server on which to load an installed server network library.
  3. Make sure that TCP/IP appears in the Enabled Protocols list.
  4. To find the port number, in the Enabled Protocols list, click TCP/IP, and then click Properties. The Properties dialog box displays the port number.

There is an known bug: SQL Server May Not Listen on TCP/IP Sockets When TCP/IP is the Only Protocol

In a SQL Server 2000 custom installation, if TCP/IP is the only selected protocol and all other protocols are disabled, SQL Server may not initialize and listen on TCP/IP sockets. The Server Network Utility shows that it is listening only on TCP/IP port 1433 even though it is not. To identify if SQL Server is not listening on TCP/IP, check to see if the value for TcpPort in the following registry key is incorrectly set to blank or empty:

HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SQL Server/ [Instance Name]/MSSQLServer/SuperSocketNetLib/Tcp/REG_SZ TcpPort=

To work around this problem, follow these steps:

  1. Start Registry Editor (Regedt32.exe).
  2. Locate the TcpPort value in the following key in the registry:

    Named instance:

    HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SQL Server/[InstanceName]/MSSQLServer/SuperSocketNetLib/Tcp/TcpPort

    Default instance:

    HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSSQLServer
    /MSSQLServer/SuperSocketNetLib/TCP/TcpPort

     

  3. . On the Edit menu, click String. Enter either of the following values:
    a. Type the port number you want. -or-
    b. Enter a value of 0 to have SQL Server dynamically detect and assign a port the next time SQL Server starts.

     

  4. Click OK.
  5. Quit Registry Editor.

SQL Server 2000 Service Pack 4 (SP4):

You are running a version of Microsoft SQL Server 2000 or Microsoft SQL Server 2000 Desktop Engine (also called MSDE) that has known security vulnerabilities when used in conjunction with the Microsoft Windows Server 2003 family. To reduce your computer's vulnerability to certain virus attacks, the TCP/IP and UDP network ports of Microsoft SQL Server 2000, MSDE, or both have been disabled. To enable these ports, you must install SQL Server 2000 Service Pack 3a, or the most recent service pack for Microsoft SQL Server 2000 or MSDE from    http://www.microsoft.com/sql/downloads/2000/sp4.mspx.

转载地址:http://beici.baihongyu.com/

你可能感兴趣的文章
mint/ubuntu安装搜狗输入法
查看>>
C++动态申请数组和参数传递问题
查看>>
opencv学习——在MFC中读取和显示图像
查看>>
C/C++中关于动态生成一维数组和二维数组的学习
查看>>
JVM并发机制探讨—内存模型、内存可见性和指令重排序
查看>>
nginx+tomcat+memcached (msm)实现 session同步复制
查看>>
c++模板与泛型编程
查看>>
WAV文件解析
查看>>
WPF中PATH使用AI导出SVG的方法
查看>>
WPF UI&控件免费开源库
查看>>
QT打开项目提示no valid settings file could be found
查看>>
Win10+VS+ESP32环境搭建
查看>>
android 代码实现圆角
查看>>
flutter-解析json
查看>>
android中shader的使用
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
转载一个webview开车指南以及实际项目中的使用
查看>>
android中对于非属性动画的整理
查看>>