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?
Using SQL Server Management StudioIn Object Explorer, right-click a server and select Properties. Select the Connections node. Under Remote server connections, select or clear the Allow remote connections to this server check box.
Security & ConnectionsRight-click on your server name and click 'Properties'. Go to the Security page for Server Authentication, and select 'SQL Server and Windows Authentication' mode. Then, go to the Connections page and ensure that "Allow remote connections to this server" is checked, and click OK.
Using SQL Server Management StudioSelect the Connections node. Under Connections, in the Max number of concurrent connections box, type or select a value from 0 through 32767 to set the maximum number of users that are allowed to connect simultaneously to the instance of SQL Server. Restart SQL Server.
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.
Open the Sql Server Configuration Manager (Start -> Programs -> Microsoft SQL Server 2008 -> Configuration Tools)
Expand SQL Server Network Configuration -> [Your Server Instance]
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With