Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
180 views
in Technique[技术] by (71.8m points)

java - How can I make MS SQL Server available for connections?

I'm trying to connect to MS SQL Server (running on my machine) from a Java program. I'm getting the following long winded exception:

Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".

When I check "Properties" and click "View Connection Properties" in the Object Explorer of MS SQL, I find that the "Server is Unavailable." This seems possibly related to the exception message.

How can I make the server available?

Edit:

I am using SQL Server 2008, and I have now enabled TCP/IP, and restarted my instance. I am still told that "Server is unavailable."

Any other ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I ran into this problem as well. The MSKB article applies to SQL server 2005.

As the "SQL Server Surface Area Configuration" tool has been dropped in lieu of "Facets" - this wasn't obvious to me.

I resolved this by setting the TCPAll port and enabling the relevant IP.


Steps

  1. Open the Sql Server Configuration Manager (Start -> Programs -> Microsoft SQL Server 2008 -> Configuration Tools)

  2. Expand SQL Server Network Configuration -> [Your Server Instance]

  3. Double click TCP/IP

    • Under Protocol:

      Ensure Enabled is Yes

    • Under IP Addresses:

      Scroll to the bottom and set the TCP Port under IPAll, (1433 by default)

      Find the IP address you want to connect to and set Enabled and Active to Yes


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...