Enterprise Integration Zone is brought to you in partnership with:

Lijin Joseji is a Senior IT Specialist working with IBM Global Business Services since 2008. He has been involved in different projects which make use of WebSphere eXtream deployment components as well as other open source technologies. His areas of expertise includes design and development of J2EE applications, WebSphere eXtream Deployment Components such as IBM Object Grid, Compute Grid, SOA Architecture, open source frameworks such as Spring, Hibernate, Web service frameworks, NoSQL & SQL Databases and mobile development. Currently he works and specializes in WebSphere eXtreme Scale and WebSphere Extended Deployment Compute Grid and Object Grid related Projects, NoSQL dabatases, Android Development and Cloud computing. He used to write his technical views and experience through his Blog called OrangeSlate.com. Lijin is a DZone MVB and is not an employee of DZone and has posted 5 posts at DZone. You can read more from them at their website. View Full User Profile

Six Possible Solutions For JDBC – SQL Server Connection Problem

07.28.2012
| 10497 views |
  • submit to reddit
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.”.

  1. 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)
  2. 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
  3. 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
Published at DZone with permission of Lijin Joseji, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)