Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-03-20
2
Medium Priority
?
529 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 28

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 26

Accepted Solution

by:
Tomas Helgi Johannsson earned 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

772 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