Not sure if I fully understand the question. But the internal applications should be fine about the port number unless there are also firewalls internally, in which case you just allow the port through there.
For the external access, I'd consider a static port so you can stop doing what you have to do. In an ideal world you'd only really expose your SQL Server to the web server itself externally, so if the firewall can just trust the webservers IP only that is a good thing to do only, instead of just being wide open for that port for any incoming traffic.
But you just ned to set an static port in the network config:
So instead of a 0 for dynamic ports, type a port number in for the TCP Port you wish to use.
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)...
...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;...
Best Answer
Yes. You can query sys.dm_exec_connections to identify a session from the client's TCP port (column
client_tcp_port
).For example: