Few days back I was writing a client server Java application using MS SQL server as back end. I built n tested the application and sent it to my client and the application did not started which was very much expected, but I never thought that debugging this will eat my one full F***ing week. Today I debugged it successfully after week longs effort, so I thought let me post it here so that some one else may not waste his/her time on such an issue, even though there are many solutions over internet, none are confident. So here it goes :
There are many reasons behind this error which are as follows :
1) URL string is not correct
2) Port which you specified is not the one at which the server is listening.
3) Your machine is not connected to network (sounds weired, yes SQL server needs the TCP stack to be installed, so either connect the machine to the network or configure a loopback interface if you want your application to run as stand alone)
4) Check your service pack (this was my problem)
5) Firewall is preventing it to connect
Follow this Approach to solve this exception
The first thing one should check when u get this problem is "the URL string" in your server.xml file for the IP address/name of the SQL server is correct and it is reachable - confirm this by pinging the server.
if URL is correct
Check "the port which you specified" in the URL string, default is 1433 check this against the server configuration. Server port configuration can be checked by opening server network utility from - start->All programs->MS SQL server -> server network utility. In this you will find the disabled protocols and the enabled protocols. In enabled protocols list Named pipes and TCP should be listed. Select TCP and click on properties it will show the port number the server is listening on. Repeat this to confirm Client network utility also - start->All programs->MS SQL server -> Client network utility
if port is also matching
Check if the server is listening on that port which is shown in the server network utility. Follow this procedure to check this.
Go to command prompt and give following command :
telnet localhost or IP address (of the server if it is on the network) port number
eg. : telnet localhost 1433
When this command is issued a blank screen should come, if you get a message like "Could not open connection > to the host, on port > 1433" then it is confirmed that the server is not listening on the specified port number.
You can also confirm this from the SQL server logs go to program files->MS sql server-> MSSQL -> LOG -> and open the most recent errorlog file. If it shows a log as follows :
SQL server listening on Shared Memory, Named Pipes
that means it is not listening on TCP, when it is listening on TCP the log will be as follows:
SQL server listening on TCP, Shared Memory, Named Pipes
But this log is not very consistent so don't depend on this the Telnet method is the best.
if server is not listening on port which it shows in server network utility
Check your service pack. If you are running SP2 or SP3 then what ever you do the server will not listen on that because of the some weired security vulnerabilities, So either have SP1 or SP4(recommended)you can find the SP4 at Microsoft site install all the exe's listed at this site.
If you already have SP4 or installed and is still not working
Check your firewall either turn it off or create an exception for this port.
This should solve most of the problems if any one still have issues refer to the Microsoft Site or post a mail to me - sun.1601@gmail.com
Hope this would help a few
-sun
2 comments:
i am getting same same problem when folloing the above format why.can u send to me clearly
Mail me.. I am sure you are missing some thing...
Post a Comment