Here in this post I am writing about some possible solutions of JDBC – MS SQL server connection problem. During my work I had faced this problem and tried a little hard to findout the solution. In our project when we tried to connect to MSSQL Server, through its default port 1433 it thrown an exception as follows. Hope this will be helpful to you.
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.”.
- Enable SQL Server Network Configuration
- For this, go to Start Menu => Microsoft SQL Server 2008 => Configuration Tools => SQL Server Configuration Manager
- Go to SQL Server Network Configuration => Protocols for [Instance Name] => TCP/IP
- Instance name is the one in which you have created your database. By default it will be SQLEXPRESS
- Make it enable (if disabled)
- Check the port on which SQL server is running
- For this, go to Start Menu => Microsoft SQL Server 2008 => Configuration Tools => SQL Server Configuration Manager
- Go to SQL Server Network Configuration => Protocols for [Instance Name] => TCP/IP
- Instance name is the one in which you have created your database. By default it will be SQLEXPRESS
- Right click on that and Go to Properties => IP Addresses tab => IP All section
- There you will find TCP Dynamic Ports property and we have to consider that port number instead of default port 1433
- If you still facing the issue then please check Registry
- Go to Start Menu => run => regedit
- Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.[Instance Name]\MSSQLServer\SuperSocketNetLib\Tcp\IPAll and check the value of key TcpDynamicPorts. we have to consider that port number instead of default port 1433
Can i get the web page plz
Thanks very much! You solved my problem in one minute! Step 5 was the solution. Very good article!
Hi Lijin, thank you very much for this article! Step 5 solved my problem!
MY VERSION FOR ECLIPSE IS 3.4 AND I AM USING SQL SERVER 2005..
HI THERE
I AM FACING A PROBLEM WHILE CONNECTING THROUGH ECLIPSE.
EVERYTIME I EXECUTE MY CODE FOR CONNECTION, I AM GETTING ERROR: From Base Daocom.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ‘amandeep’. The user is not associated with a trusted SQL Server connection.
java.lang.NullPointerException
COULD YOU HELP IN THIS ISSUE
THANX IN ADVANCE….
thank you very much for your valuable information
Thanks Tariq. You know I wasted my 2 days because of this problem. 🙂 So I thought of putting this in my blog hoping that you people can save your valuable hours… honestly 🙂
Respected Sir,
You are great what a point you just tell us i think most of the problem occur due to no 5 point that u cover.
Again Thanks
Truly Regards,
Tariq
Thanks for your good words Phil. 🙂
Thanks man. You saved the day with this post.
I was pulling my hair out and so did some googeling.
One of the pages that came up was this post.
Steps 5 & 6 where what solved the problem.
Thanks heaps 🙂
please send this web page to me
Six Possible solutions for JDBC – SQL Server Connection problem
saeedshafiee@ymail.com