Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

determine sql instance port number

843859Oct 2 2007 — edited Nov 20 2014
According 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2007
Added on Oct 2 2007
2 comments
71 views