Solved

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

Posted on 2014-03-20
2
306 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 27

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
junit as external jar or library 7 37
batch vs regular insert in spring DAO 2 20
Substring works but need to tweak it 14 31
SQL server client app 3 26
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…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

685 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