determine sql instance port number
843859Oct 2 2007 — edited Nov 20 2014According to this page on MS: http://support.microsoft.com/kb/313225
To connect to a named instance through the Microsoft SQL Server 2000 Driver for JDBC, you must specify the port number that is associated with the named instance, instead of the name of the named instance as shown earlier.
Ok, that's easy to do. My problem is that my sql database(actually most of them) uses dynamic port numbers. Meaning if I restart the database and there is a process that uses that port, then that instance will run on a different port.
So I cannot write a java code that connects to that instance using
jdbc:microsoft:sqlserver://yourServerName:1433
because if the port changes, then it won't work. I would first need to determine the port number. Is there any way to do that in java? 10x