I'm trying to connect to a Microsoft SQL server via java, and I have no guarantees as to what the port number will be.
There are methods that I have found for getting the port number, but they all seem to not work or require signifigant user interraction: How to find the port for MS SQL Server 2008?
(The netstat method only works if a session is already open to the SQL server, which is not guaranteed)
The simplest one perhaps would be the registry, but there are many places in the registry to look based on the "instance name" and if there is a simpler way I would love to know it.