Spring Boot connect to remote ip

Viewed 805

I need to connect to remote ip database, the ip has itself a port number associated with it. My database port is 1433.

I am using the following connection string in my application.properties

spring.datasource.url=jdbc:sqlserver://x.x.x.x:XXXX:1433;databaseName=test

I am getting connection error due to invalid port. How to do that?

1 Answers

x.x.x.x:XXXX:1433.

This doesn't make any sense. IP cannot have a port associated with it. IP will get you till the machine; and port number will take you to the app which listens to that port.

It has to be either XXXX or 1433. Not both!

Edit

What you should do is, talk to your network admin folks to configure port forwarding on your NAT - this means that the NAT will listen on a port you specify, and all communication which reaches this port will be forwarded to the MS SQL Servers internal IP + another port you specify, for example: 148.25.6.22:1433 => 172.16.0.61:1433. Now, if your appserver connects to 148.25.6.22:1433, the packets will reach the MS SQL Server at port 1433.

A similar question: https://stackoverflow.com/a/31619341/6785908

Related