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!

Java Database Connectivity (JDBC) - determine sql instance port number

843859Dec 28 2009 — edited Jan 8 2010
To connect to a named instance through the Microsoft SQL Server Driver for JDBC, you must specify the port number that is associated with the named instance
e.g.: "jdbc:sqlserver://localhost:5002;DatabaseName=TestDB"

My problem is that my sql database(actually most of them) uses dynamic port numbers. If I restart the my database then sql server instance might use diffrent port.

So it is not possible to give hard coded value for port.
e.g "jdbc:sqlserver://localhost:5002;DatabaseName=TestDB"
because if the port changes, then it won't work. I would first need to determine the port number.

Is there any way to setup jdbc connection without specifying port number?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 5 2010
Added on Dec 28 2009
20 comments
1,385 views