1

I have a SQL server names as MS8AT09\AT09. I am able to login to the server through Microsoft SQL server Management studio. While trying to login to same server through JDBC I am facing the error as

"The TCP/IP connection to host XXXXXX, Port 1433 has failed. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall".

Please help.

  • 1
    Is the instance running on default port 1433? – Kin Shah Jan 21 '15 at 12:23
  • Firewall? Are you certain SSMS connects using the same protocol? – Colin 't Hart Jan 21 '15 at 13:35
  • Show your connection string so we don't have to guess how you're trying to connect. – Aaron Bertrand Jan 21 '15 at 14:51
3

It is unlikely that a named instance is running on port 1433, unless you explicitly set it as such. I also suspect that SSMS is using shared memory (if local) or named pipes (if remote), unlike JDBC which is using TCP/IP (and I don't know how to set JDBC to use a different protocol).

From this documentation, it seems your connection string should be:

jdbc:sqlserver://MS8AT09;instanceName=AT09;...

With no port designation. You could also try using the IP address instead of the name, in case name resolution is hampered for some reason.

Please check what port the instance is running on (look at SQL Server Configuration Manager)...

enter image description here

...and confirm your connection string does not hard-code a port that is different (JDBC might ). Do not hard-code the dynamic port, because it may not be the port used next time SQL Server starts. From Microsoft's documentation:

We recommend that the port number always be specified, as this is more secure than using sqlbrowser.

So, you may want to set your named instance to run on a specific port number, instead of using a dynamic port (the default), and then hard-coding that port number in the JDBC connection string. You can use the one that the instance was using dynamically, since you know it isn't in use by anything else. Also see KB #823938. So your connection string would become (assuming you used port 56737):

jdbc:sqlserver://192.168.0.65;instanceName=AT09;port=56737;...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.