Solved

jdbc database connection to the sql server is created with dynamic ports

Posted on 2014-03-20
2
276 Views
Last Modified: 2014-03-22
hi,

Need to create jdbc connection to sql server 2008,The problem is the port is dynamic.
is there any way in which database connection to the server is created with dynamic ports or in simple words without providing the port no.

ex.
Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
URL =jdbc:sqlserver://localhost:XXXXXXXXX;DatabaseName=test;

XXXX -> This can be any port i.e 1433,1435 etc
0
Comment
Question by:Rocking
2 Comments
 
LVL 26

Expert Comment

by:dpearson
ID: 39943214
If the port is dynamic, I think you either need a way to pass that value to the Java client (so it can be entered in the connection string) or you'd need to use some port mapping logic (e.g. in a firewall) to handle the routing.

If you went with the port mapping approach, then the client would always connect to a fixed port number, but the router would map that to the dynamic port.  But doing that would require a pretty skilled network guy to set that up.

Doug
0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 total points
ID: 39943973
Hi!

If you allow named connections you can connect to the instance using
jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;

see here for more info

http://technet.microsoft.com/en-us/library/ms378428.aspx

Regards,
    Tomas Helgi
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question