JDBC串連SqlServer2000出現”Connection refused: connect”的解決方案

來源:互聯網
上載者:User

JDBC串連SqlServer2000出現"Connection refused: connect"的解決方案

 

錯誤資訊如下所示:

  1. java.sql.SQLException: Network error IOException: Connection refused: connect
  2.  at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:385)
  3.  at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
  4.  at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:182)
  5.  at java.sql.DriverManager.getConnection(Unknown Source)
  6.  at java.sql.DriverManager.getConnection(Unknown Source)
  7.  at test.Test.main(Test.java:33)
  8. Caused by: java.net.ConnectException: Connection refused: connect
  9.  at java.net.PlainSocketImpl.socketConnect(Native Method)
  10.  at java.net.PlainSocketImpl.doConnect(Unknown Source)
  11.  at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
  12.  at java.net.PlainSocketImpl.connect(Unknown Source)
  13.  at java.net.SocksSocketImpl.connect(Unknown Source)
  14.  at java.net.Socket.connect(Unknown Source)
  15.  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  16.  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  17.  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  18.  at java.lang.reflect.Method.invoke(Unknown Source)
  19.  at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:304)
  20.  at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:255)
  21.  at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:310)
  22.  ... 5 more

 

 

解決方案如下:

一.查看連接埠資訊

使用JDBC在預設連接埠1433上串連SQL Server獲得connection refused異常,大致異常資訊為:
The TCP/IP connection to the host  has failed. java.net.ConnectException: Connection refused。

1.使用telnet 127.0.0.1 1433測試,得到如下資訊:
  正在串連到127.0.0.1...不能開啟到主機的串連, 在連接埠 1433: 串連失敗表示1433連接埠沒有

  開啟

2.檢查SQL Server服務已經啟動。於是用網路工具掃描連接埠,發現和SQL Server服務相關的連接埠

   為1109和1434。不過1434為UDP連接埠,所以當前的串連連接埠應為1109。可以使用SQL Server的

 “伺服器實用網路工具”修改預設連接埠。開啟“伺服器使用網路工具”後,在“常規”選項

  卡中的“啟用的協議”列表中,選擇“TCP/IP”,然後點擊“屬性”按鈕,就可以看到預設

  的連接埠值。修改後,重啟SQL Server服務,即可使用修改後的連接埠串連伺服器。

 

二.安裝更新

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.

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.