2

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?

Jerin
  • 35
  • 1
  • 7

1 Answers1

1

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

so-random-dude
  • 15,277
  • 10
  • 68
  • 113
  • I am using the remote machine of my workstation. so ip is the public ip of the workstation and port is for each machine. – Jerin Apr 09 '20 at 19:20
  • You have to talk to the network admin whoever owns that NAT and ask them to map a port for you!. Edited my answer – so-random-dude Apr 09 '20 at 19:33