sheetal mahandule
sheetal mahandule

Reputation: 23

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host , port 1071 has failed. Error: "Connect time out

I am upgrading my project from java 8 to 21 and springboot 2.x to 3.x, I am getting this error while connecting to microsoft server database.

Stack trace:

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The TCP/IP connection to the host xyz,  port 1071 has failed. Error: "Connect timed out. 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.".)
    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549) ~[commons-dbcp-1.4.jar!/:1.4]
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388) ~[commons-dbcp-1.4.jar!/:1.4]
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) ~[commons-dbcp-1.4.jar!/:1.4]
    at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160) ~[spring-jdbc-6.1.11.jar!/:6.1.11]
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118) ~[spring-jdbc-6.1.11.jar!/:6.1.11]
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81) ~[spring-jdbc-6.1.11.jar!/:6.1.11]
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:388) ~[spring-jdbc-6.1.11.jar!/:6.1.11]
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:476) ~[spring-jdbc-6.1.11.jar!/:6.1.11]
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:486) ~[spring-jdbc-6.1.11.jar!/:6.1.11]
    at 

Upvotes: 0

Views: 80

Answers (1)

Rahul Timbaliya
Rahul Timbaliya

Reputation: 36

Please follow this step and check.

  1. Open Control Panel > System And Security > Windows Defender Firewall > `Advanced Settings

  2. Click on Inbound Rules > New Rules

enter image description here

  1. Select Port from the option

enter image description here

  1. Select TCP and specified the Port No Or Select All Local Ports

enter image description here

  1. Other setting as it is and give name of your rule and save
  2. Follow Same Process For the Outbound Rules

TCP Configuration In SQL Server Configuration Manager

  • Open SQL Server Configuration Manager
  • Go to SQL Server Network Configuration
  • And Select Server Instance From the list
  • Select TCP/IP and go to the IP Addresses
  • Check the TCP Port
  • Enabled the TCP/IP Property

enter image description here

Upvotes: 0

Related Questions